Re: [PATCH 0/3] Staging: qlge: Rename of function prefix ql_ to qlge_

2019-10-24 Thread Greg KH
On Fri, Oct 25, 2019 at 12:29:38AM +0300, Samuil Ivanov wrote:
> In terms of namespace, the driver uses either qlge_, ql_ (used by
> other qlogic drivers, with clashes, ex: ql_sem_spinlock) or nothing (with
> clashes, ex: struct ob_mac_iocb_req). Rename everything to use the "qlge_"
> prefix.
> 
> So I renamed three functions to the prefered namespace "qlge",
> and updated the occurrences in the driver.
> 
> Samuil Ivanov (3):
>   Staging: qlge: Rename prefix of a function to qlge
>   Staging: qlge: Rename prefix of a function to qlge
>   Staging: qlge: Rename prefix of a function to qlge

You sent 3 patches that do different things, yet have the same identical
subject line :(

Please fix up and resend the series.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 09/15] staging: exfat: Clean up return codes - FFS_FORMATERR

2019-10-24 Thread Greg Kroah-Hartman
On Thu, Oct 24, 2019 at 11:53:20AM -0400, Valdis Kletnieks wrote:
> Convert FFS_FORMATERR to -EFSCORRUPTED
> 
> Signed-off-by: Valdis Kletnieks 
> ---
>  drivers/staging/exfat/exfat.h   | 3 ++-
>  drivers/staging/exfat/exfat_core.c  | 4 ++--
>  drivers/staging/exfat/exfat_super.c | 2 +-
>  3 files changed, 5 insertions(+), 4 deletions(-)

This causes build errors, maybe because I didn't take your other series.

So I'm stopping here, please rebase and resend.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 8/8] staging: exfat: Update TODO

2019-10-24 Thread Greg Kroah-Hartman
On Wed, Oct 23, 2019 at 01:27:51AM -0400, Valdis Kletnieks wrote:
> Signed-off-by: Valdis Kletnieks 
> ---
>  drivers/staging/exfat/TODO | 20 
>  1 file changed, 8 insertions(+), 12 deletions(-)

I can't take patches without any changelog text, sorry :(
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/8] staging: exfat: Clean up namespace pollution, part 1

2019-10-24 Thread Greg Kroah-Hartman
On Wed, Oct 23, 2019 at 01:27:44AM -0400, Valdis Kletnieks wrote:
> Make as much as possible static.  We're over-exuberant here for the benefit
> of a following patch, as the compiler will flag now-unused static code

This adds a bunch of compiler warnings, which isn't ok.  Please fix this
up to be correct and not add build warnings, as it just hides real
issues.

I'll drop this series and wait for a new version with this fixed up.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: vc04_services: add space to fix check warning

2019-10-24 Thread Greg KH
On Wed, Oct 16, 2019 at 12:09:22AM +0100, Jules Irenge wrote:
> Add space betwen operator to fix check warning.
> Issue detected by checkpatch tool.
> 
> Signed-off-by: Jules Irenge 
> ---
>  drivers/staging/vc04_services/interface/vchi/vchi_cfg.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/vc04_services/interface/vchi/vchi_cfg.h 
> b/drivers/staging/vc04_services/interface/vchi/vchi_cfg.h
> index dbb6a5f07a79..192c287503a5 100644
> --- a/drivers/staging/vc04_services/interface/vchi/vchi_cfg.h
> +++ b/drivers/staging/vc04_services/interface/vchi/vchi_cfg.h
> @@ -163,9 +163,9 @@
>   * by suspending parsing as the comment above says, but we don't.
>   * This sweeps the issue under the carpet.
>   */
> -#if VCHI_RX_MSG_QUEUE_SIZE < (VCHI_MAX_MSG_SIZE/16 + 1) * VCHI_NUM_READ_SLOTS
> +#if VCHI_RX_MSG_QUEUE_SIZE < (VCHI_MAX_MSG_SIZE / 16 + 1) * 
> VCHI_NUM_READ_SLOTS
>  #  undef VCHI_RX_MSG_QUEUE_SIZE
> -#  define VCHI_RX_MSG_QUEUE_SIZE ((VCHI_MAX_MSG_SIZE/16 + 1) * 
> VCHI_NUM_READ_SLOTS)
> +#  define VCHI_RX_MSG_QUEUE_SIZE ((VCHI_MAX_MSG_SIZE / 16 + 1) * 
> VCHI_NUM_READ_SLOTS)
>  #endif
>  
>  /* How many bulk transmits can we have pending. Once exhausted,
> -- 
> 2.21.0

Path does not apply to my tree at all :(
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/4] staging: KPC2000: kpc2000_spi.c: Fix style issues (misaligned brace)

2019-10-24 Thread Greg KH
On Fri, Oct 18, 2019 at 12:09:48AM -0700, Chandra Annamaneni wrote:
> Resolved: ERROR: else should follow close brace '}'
> 
> Signed-off-by: Chandra Annamaneni 
> ---
> Previous versions of these patches were not split into different 
> patches, did not have different patch numbers and did not have the
> keyword staging. The previous version of this patch had the wrong 
> description and subject.

Ok, but I only see 1 patch here.

Can you resend the whole series properly, with a "v2" showing what
changed?

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/3] Staging: qlge: Rename prefix of a function to qlge

2019-10-24 Thread Samuil Ivanov
Function ql_mb_about_fw renamed to
qlge_mb_about_fw and it's clients updated.

Signed-off-by: Samuil Ivanov 
---
 drivers/staging/qlge/qlge.h  | 2 +-
 drivers/staging/qlge/qlge_main.c | 2 +-
 drivers/staging/qlge/qlge_mpi.c  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/qlge/qlge.h b/drivers/staging/qlge/qlge.h
index d3f10c95c781..649f1fd10739 100644
--- a/drivers/staging/qlge/qlge.h
+++ b/drivers/staging/qlge/qlge.h
@@ -2266,7 +2266,7 @@ int qlge_soft_reset_mpi_risc(struct ql_adapter *qdev);
 int ql_dump_risc_ram_area(struct ql_adapter *qdev, void *buf, u32 ram_addr,
  int word_count);
 int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump 
*mpi_coredump);
-int ql_mb_about_fw(struct ql_adapter *qdev);
+int qlge_mb_about_fw(struct ql_adapter *qdev);
 int ql_mb_wol_set_magic(struct ql_adapter *qdev, u32 enable_wol);
 int ql_mb_wol_mode(struct ql_adapter *qdev, u32 wol);
 int ql_mb_set_led_cfg(struct ql_adapter *qdev, u32 led_config);
diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c
index 0c381d91faa6..b8f4f4e5e579 100644
--- a/drivers/staging/qlge/qlge_main.c
+++ b/drivers/staging/qlge/qlge_main.c
@@ -880,7 +880,7 @@ static int ql_8000_port_initialize(struct ql_adapter *qdev)
 * Get MPI firmware version for driver banner
 * and ethool info.
 */
-   status = ql_mb_about_fw(qdev);
+   status = qlge_mb_about_fw(qdev);
if (status)
goto exit;
status = ql_mb_get_fw_state(qdev);
diff --git a/drivers/staging/qlge/qlge_mpi.c b/drivers/staging/qlge/qlge_mpi.c
index ccffe0b256fa..092695719c58 100644
--- a/drivers/staging/qlge/qlge_mpi.c
+++ b/drivers/staging/qlge/qlge_mpi.c
@@ -612,7 +612,7 @@ static int ql_mailbox_command(struct ql_adapter *qdev, 
struct mbox_params *mbcp)
  * driver banner and for ethtool info.
  * Returns zero on success.
  */
-int ql_mb_about_fw(struct ql_adapter *qdev)
+int qlge_mb_about_fw(struct ql_adapter *qdev)
 {
struct mbox_params mbc;
struct mbox_params *mbcp = 
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/3] Staging: qlge: Rename prefix of a function to qlge

2019-10-24 Thread Samuil Ivanov
This is from the TODO list:
In terms of namespace, the driver uses either qlge_, ql_ (used by
other qlogic drivers, with clashes, ex: ql_sem_spinlock) or nothing (with
clashes, ex: struct ob_mac_iocb_req). Rename everything to use the "qlge_"
prefix

Function ql_soft_reset_mpi_risc renamed to
qlge_soft_reset_mpi_risc and it's clients updated.

Signed-off-by: Samuil Ivanov 
---
 drivers/staging/qlge/qlge.h | 2 +-
 drivers/staging/qlge/qlge_dbg.c | 2 +-
 drivers/staging/qlge/qlge_mpi.c | 5 +++--
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/qlge/qlge.h b/drivers/staging/qlge/qlge.h
index 6ec7e3ce3863..e9f1363c5bf2 100644
--- a/drivers/staging/qlge/qlge.h
+++ b/drivers/staging/qlge/qlge.h
@@ -2262,7 +2262,7 @@ int ql_write_mpi_reg(struct ql_adapter *qdev, u32 reg, 
u32 data);
 int ql_unpause_mpi_risc(struct ql_adapter *qdev);
 int ql_pause_mpi_risc(struct ql_adapter *qdev);
 int ql_hard_reset_mpi_risc(struct ql_adapter *qdev);
-int ql_soft_reset_mpi_risc(struct ql_adapter *qdev);
+int qlge_soft_reset_mpi_risc(struct ql_adapter *qdev);
 int ql_dump_risc_ram_area(struct ql_adapter *qdev, void *buf, u32 ram_addr,
  int word_count);
 int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump 
*mpi_coredump);
diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c
index 019b7e6a1b7a..df5344e113ca 100644
--- a/drivers/staging/qlge/qlge_dbg.c
+++ b/drivers/staging/qlge/qlge_dbg.c
@@ -1312,7 +1312,7 @@ void ql_get_dump(struct ql_adapter *qdev, void *buff)
 
if (!test_bit(QL_FRC_COREDUMP, >flags)) {
if (!ql_core_dump(qdev, buff))
-   ql_soft_reset_mpi_risc(qdev);
+   qlge_soft_reset_mpi_risc(qdev);
else
netif_err(qdev, drv, qdev->ndev, "coredump failed!\n");
} else {
diff --git a/drivers/staging/qlge/qlge_mpi.c b/drivers/staging/qlge/qlge_mpi.c
index 9e4226ab..efe893935929 100644
--- a/drivers/staging/qlge/qlge_mpi.c
+++ b/drivers/staging/qlge/qlge_mpi.c
@@ -88,9 +88,10 @@ int ql_write_mpi_reg(struct ql_adapter *qdev, u32 reg, u32 
data)
return status;
 }
 
-int ql_soft_reset_mpi_risc(struct ql_adapter *qdev)
+int qlge_soft_reset_mpi_risc(struct ql_adapter *qdev)
 {
int status;
+
status = ql_write_mpi_reg(qdev, 0x1010, 1);
return status;
 }
@@ -1280,5 +1281,5 @@ void ql_mpi_reset_work(struct work_struct *work)
queue_delayed_work(qdev->workqueue,
>mpi_core_to_log, 5 * HZ);
}
-   ql_soft_reset_mpi_risc(qdev);
+   qlge_soft_reset_mpi_risc(qdev);
 }
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/3] Staging: qlge: Rename prefix of a function to qlge

2019-10-24 Thread Samuil Ivanov
Function ql_own_firmware renamed to
qlge_own_firmware and it's clients updated.

Signed-off-by: Samuil Ivanov 
---
 drivers/staging/qlge/qlge.h | 2 +-
 drivers/staging/qlge/qlge_dbg.c | 2 +-
 drivers/staging/qlge/qlge_mpi.c | 5 ++---
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/qlge/qlge.h b/drivers/staging/qlge/qlge.h
index e9f1363c5bf2..d3f10c95c781 100644
--- a/drivers/staging/qlge/qlge.h
+++ b/drivers/staging/qlge/qlge.h
@@ -2280,7 +2280,7 @@ int ql_wait_fifo_empty(struct ql_adapter *qdev);
 void ql_get_dump(struct ql_adapter *qdev, void *buff);
 netdev_tx_t ql_lb_send(struct sk_buff *skb, struct net_device *ndev);
 void ql_check_lb_frame(struct ql_adapter *, struct sk_buff *);
-int ql_own_firmware(struct ql_adapter *qdev);
+int qlge_own_firmware(struct ql_adapter *qdev);
 int ql_clean_lb_rx_ring(struct rx_ring *rx_ring, int budget);
 
 /* #define QL_ALL_DUMP */
diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c
index df5344e113ca..82bca35543d3 100644
--- a/drivers/staging/qlge/qlge_dbg.c
+++ b/drivers/staging/qlge/qlge_dbg.c
@@ -1209,7 +1209,7 @@ int ql_core_dump(struct ql_adapter *qdev, struct 
ql_mpi_coredump *mpi_coredump)
 
 static void ql_get_core_dump(struct ql_adapter *qdev)
 {
-   if (!ql_own_firmware(qdev)) {
+   if (!qlge_own_firmware(qdev)) {
netif_err(qdev, drv, qdev->ndev, "Don't own firmware!\n");
return;
}
diff --git a/drivers/staging/qlge/qlge_mpi.c b/drivers/staging/qlge/qlge_mpi.c
index efe893935929..ccffe0b256fa 100644
--- a/drivers/staging/qlge/qlge_mpi.c
+++ b/drivers/staging/qlge/qlge_mpi.c
@@ -101,7 +101,7 @@ int qlge_soft_reset_mpi_risc(struct ql_adapter *qdev)
  * we are the higher function and the lower function
  * is not enabled.
  */
-int ql_own_firmware(struct ql_adapter *qdev)
+int qlge_own_firmware(struct ql_adapter *qdev)
 {
u32 temp;
 
@@ -122,7 +122,6 @@ int ql_own_firmware(struct ql_adapter *qdev)
return 1;
 
return 0;
-
 }
 
 static int ql_get_mb_sts(struct ql_adapter *qdev, struct mbox_params *mbcp)
@@ -1270,7 +1269,7 @@ void ql_mpi_reset_work(struct work_struct *work)
/* If we're not the dominant NIC function,
 * then there is nothing to do.
 */
-   if (!ql_own_firmware(qdev)) {
+   if (!qlge_own_firmware(qdev)) {
netif_err(qdev, drv, qdev->ndev, "Don't own firmware!\n");
return;
}
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 0/3] Staging: qlge: Rename of function prefix ql_ to qlge_

2019-10-24 Thread Samuil Ivanov
In terms of namespace, the driver uses either qlge_, ql_ (used by
other qlogic drivers, with clashes, ex: ql_sem_spinlock) or nothing (with
clashes, ex: struct ob_mac_iocb_req). Rename everything to use the "qlge_"
prefix.

So I renamed three functions to the prefered namespace "qlge",
and updated the occurrences in the driver.

Samuil Ivanov (3):
  Staging: qlge: Rename prefix of a function to qlge
  Staging: qlge: Rename prefix of a function to qlge
  Staging: qlge: Rename prefix of a function to qlge

 drivers/staging/qlge/qlge.h  |  6 +++---
 drivers/staging/qlge/qlge_dbg.c  |  4 ++--
 drivers/staging/qlge/qlge_main.c |  2 +-
 drivers/staging/qlge/qlge_mpi.c  | 12 ++--
 4 files changed, 12 insertions(+), 12 deletions(-)

-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 04/15] staging: exfat: Clean up return codes - FFS_PERMISSIONERR

2019-10-24 Thread Joe Perches
On Thu, 2019-10-24 at 11:53 -0400, Valdis Kletnieks wrote:
> Convert FFS_PERMISSIONERR to -EPERM
[]
> diff --git a/drivers/staging/exfat/exfat_super.c 
> b/drivers/staging/exfat/exfat_super.c
[]
> @@ -2526,7 +2526,7 @@ static int exfat_unlink(struct inode *dir, struct 
> dentry *dentry)
>  
>   err = ffsRemoveFile(dir, &(EXFAT_I(inode)->fid));
>   if (err) {
> - if (err == FFS_PERMISSIONERR)
> + if (err == -EPERM)
>   err = -EPERM;
>   else
>   err = -EIO;
[]
> @@ -2746,7 +2746,7 @@ static int exfat_rename(struct inode *old_dir, struct 
> dentry *old_dentry,
>   err = ffsMoveFile(old_dir, &(EXFAT_I(old_inode)->fid), new_dir,
> new_dentry);
>   if (err) {
> - if (err == FFS_PERMISSIONERR)
> + if (err == -EPERM)
>   err = -EPERM;
>   else if (err == FFS_INVALIDPATH)
>   err = -EINVAL;

These test and assign to same value blocks look kinda silly.


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [Outreachy kernel] Re: [PATCH v2 1/5] staging: octeon: remove typedef declaration for cvmx_wqe

2019-10-24 Thread Julia Lawall



On Thu, 24 Oct 2019, Paul Burton wrote:

> Hi Wambui, Julia,
>
> Side-note: Wambui, your mail client seems to have added this header:
>
>   Reply-To: alpine.DEB.2.21.1910240722070.2771@hadrien
>
> This is the ID of the message you replied to (ie. this is the same value
> that the In-Reply-To: header has). You should probably figure out how
> that happened, or you're going to miss responses when people reply
> without noticing the bogus email address.

This is somehow related to me...  I don't know if the problem comes from
me or from Wambui.

julia

>
> On Thu, Oct 24, 2019 at 01:00:20PM +0300, Wambui Karuga wrote:
> > On Thu, Oct 24, 2019 at 07:26:59AM +0200, Julia Lawall wrote:
> > > > If you're making significant changes to this driver, please test them
> > > > using the MIPS cavium_octeon_defconfig which is where this driver is
> > > > actually used.
> > > >
> > > > This driver has broken builds a few times recently which makes me very
> > > > tempted to ask that we stop allowing it to be built with COMPILE_TEST.
> > > > The whole octeon-stubs.h thing is a horrible hack anyway...
> > >
> > > Wambui,
> > >
> > > Please figure out what went wrong here.  Are there two sets of typedefs
> > > that should have been updated?
> > >
> > I managed to reproduce these build errors and finally noticed that the
> > "octeon-stubs.h" header is only included when CONFIG_CAVIUM_OCTEON_SOC
> > is not defined, therefore compiling properly for COMPILE_TEST but will
> > actually fail when compiled with CONFIG_CAVIUM_OCTEON_SOC is set since
> > the functions will try to use the definitions in
> > arch/mips/include/asm/octeon/ that don't have the changes.
> >
> > Paul, please tell me if this is correct?
>
> Yes, that's correct. The driver was written to use the headers in
> arch/mips/include/asm/octeon, and then recently the octeon-stubs.h
> header was added which duplicates lots of the MIPS & Octeon-specific
> header content in one huge monstrous file.
>
> I'm all for improving compile test coverage, but I think octeon-stubs.h
> in its short life has already proven itself to be a bad way to achieve
> that goal[1][2][3].
>
> > > Others,
> > >
> > > Would it be reasonable to put the information about how the driver should
> > > be compied in the TODO file?  git grep cavium_octeon_defconfig in the
> > > octeon directory turns up nothing.
>
> It wouldn't hurt. I'd argue that Kconfig already provides enough
> information to figure this out easily though - OCTEON_ETHERNET depends
> on CAVIUM_OCTEON_SOC || COMPILE_TEST, which ought to tell people that
> its real use is when CAVIUM_OCTEON_SOC=y. That doesn't necessarily point
> you to cavium_octeon_defconfig (though grepping for CAVIUM_OCTEON_SOC=y
> would), but that's not strictly needed anyway - any old config with
> CAVIUM_OCTEON_SOC=y would do.
>
> Thanks,
> Paul
>
> [1] 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0228ecf6128c92b47eadd2ac270c5574d9150c09
> [2] 
> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/drivers/staging/octeon?id=17a29fea086ba18b000d28439bd5cb4f2b0a527b
> [3] 
> https://storage.kernelci.org/next/master/next-20191024/mips/cavium_octeon_defconfig/gcc-8/build.log
>
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [Outreachy kernel] Re: [PATCH v2 1/5] staging: octeon: remove typedef declaration for cvmx_wqe

2019-10-24 Thread Paul Burton
Hi Wambui, Julia,

Side-note: Wambui, your mail client seems to have added this header:

  Reply-To: alpine.DEB.2.21.1910240722070.2771@hadrien

This is the ID of the message you replied to (ie. this is the same value
that the In-Reply-To: header has). You should probably figure out how
that happened, or you're going to miss responses when people reply
without noticing the bogus email address.

On Thu, Oct 24, 2019 at 01:00:20PM +0300, Wambui Karuga wrote:
> On Thu, Oct 24, 2019 at 07:26:59AM +0200, Julia Lawall wrote:
> > > If you're making significant changes to this driver, please test them
> > > using the MIPS cavium_octeon_defconfig which is where this driver is
> > > actually used.
> > >
> > > This driver has broken builds a few times recently which makes me very
> > > tempted to ask that we stop allowing it to be built with COMPILE_TEST.
> > > The whole octeon-stubs.h thing is a horrible hack anyway...
> > 
> > Wambui,
> > 
> > Please figure out what went wrong here.  Are there two sets of typedefs
> > that should have been updated?
> >
> I managed to reproduce these build errors and finally noticed that the
> "octeon-stubs.h" header is only included when CONFIG_CAVIUM_OCTEON_SOC
> is not defined, therefore compiling properly for COMPILE_TEST but will
> actually fail when compiled with CONFIG_CAVIUM_OCTEON_SOC is set since
> the functions will try to use the definitions in
> arch/mips/include/asm/octeon/ that don't have the changes.
> 
> Paul, please tell me if this is correct?

Yes, that's correct. The driver was written to use the headers in
arch/mips/include/asm/octeon, and then recently the octeon-stubs.h
header was added which duplicates lots of the MIPS & Octeon-specific
header content in one huge monstrous file.

I'm all for improving compile test coverage, but I think octeon-stubs.h
in its short life has already proven itself to be a bad way to achieve
that goal[1][2][3].

> > Others,
> > 
> > Would it be reasonable to put the information about how the driver should
> > be compied in the TODO file?  git grep cavium_octeon_defconfig in the
> > octeon directory turns up nothing.

It wouldn't hurt. I'd argue that Kconfig already provides enough
information to figure this out easily though - OCTEON_ETHERNET depends
on CAVIUM_OCTEON_SOC || COMPILE_TEST, which ought to tell people that
its real use is when CAVIUM_OCTEON_SOC=y. That doesn't necessarily point
you to cavium_octeon_defconfig (though grepping for CAVIUM_OCTEON_SOC=y
would), but that's not strictly needed anyway - any old config with
CAVIUM_OCTEON_SOC=y would do.

Thanks,
Paul

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0228ecf6128c92b47eadd2ac270c5574d9150c09
[2] 
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/drivers/staging/octeon?id=17a29fea086ba18b000d28439bd5cb4f2b0a527b
[3] 
https://storage.kernelci.org/next/master/next-20191024/mips/cavium_octeon_defconfig/gcc-8/build.log
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 01/15] staging: exfat: Clean up return codes - FFS_FULL

2019-10-24 Thread Valdis Klētnieks
On Thu, 24 Oct 2019 10:59:04 -0700, Matthew Wilcox said:
> Wouldn't it be better to do this as:

> Patch 1: Change all these defines to -Exxx and remove the stupid 
> errno-changing
> blocks like this:

Well, except for the fact that the one for FFS_MEDIAERR required splitting the
uses into -ENODEV, -EIO, and -ENOENT.

Also, "and remover the stupid blocks" would be a second change, and I *thought*
the rule was "one thing, one patch".

> That way nobody actually needs to review patches 2-n; all of the changes
> are done in patch 1.

Reviewing a patch where you know that exactly one thing is supposed to happen
means scrolling through 14 occurrences of the pattern

if (num_alloced == 0)
-   ret = FFS_FULL;
+   ret = -ENOSPC;

goes *really* fast, and those comprise most of the bulk of the patchset.

And as I already mentioned, the "stupid looking blocks" will be removed in
a future patch.


pgpYfCslQ7sA9.pgp
Description: PGP signature
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 01/15] staging: exfat: Clean up return codes - FFS_FULL

2019-10-24 Thread Matthew Wilcox
On Thu, Oct 24, 2019 at 11:53:12AM -0400, Valdis Kletnieks wrote:
> Start cleaning up the odd scheme of return codes, starting with FFS_FULL

> +++ b/drivers/staging/exfat/exfat.h
> @@ -221,7 +221,6 @@ static inline u16 get_row_index(u16 i)
>  #define FFS_PERMISSIONERR   11
>  #define FFS_NOTOPENED   12
>  #define FFS_MAXOPENED   13
> -#define FFS_FULL14
>  #define FFS_EOF 15
>  #define FFS_DIRBUSY 16
>  #define FFS_MEMORYERR   17

Wouldn't it be better to do this as:

Patch 1: Change all these defines to -Exxx and remove the stupid errno-changing
blocks like this:

> @@ -2360,7 +2360,7 @@ static int exfat_create(struct inode *dir, struct 
> dentry *dentry, umode_t mode,
>   err = -EINVAL;
>   else if (err == FFS_FILEEXIST)
>   err = -EEXIST;
> - else if (err == FFS_FULL)
> + else if (err == -ENOSPC)
>   err = -ENOSPC;
>   else if (err == FFS_NAMETOOLONG)
>   err = -ENAMETOOLONG;

then patches 2-n remove individual FFS error codes.

That way nobody actually needs to review patches 2-n; all of the changes
are done in patch 1.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 15/15] staging: exfat: Clean up return codes - FFS_SUCCESS

2019-10-24 Thread Valdis Klētnieks
On Thu, 24 Oct 2019 09:29:00 -0700, Joe Perches said:

> > -   if (sector_read(sb, sec, >buf_bh, 1) != FFS_SUCCESS) {
> > +   if (sector_read(sb, sec, >buf_bh, 1) != 0) {
>
> Probably nicer to just drop the != 0

Again, that's on the to-do list.


pgpW4nZ8xnSkz.pgp
Description: PGP signature
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 00/15] staging: exfat: Clean up return codes

2019-10-24 Thread Valdis Klētnieks
On Thu, 24 Oct 2019 09:23:24 -0700, Joe Perches said:

> All well and good, but does converting the error code from
> positive to negative have any impact on any of the code
> paths that use these return values?
>
>   if (error > 0)
> vs
>   if (error < 0)

I was keeping an eye open for that, and didn't see any.

An interesting case is the FFS_EOF patch, which fixes an actual bug. If you did
a read for length 0, it would return FFS_EOF (==15) - which would be
interpreted as the number of bytes returned by read().



pgpW1TdcVFiVK.pgp
Description: PGP signature
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/3] staging: sm750fb: align arguments with open parenthesis in file sm750_cursor.h

2019-10-24 Thread Gabriela Bittencourt
Cleans up checks of "Alignment should match open parenthesis"
in file sm750_cursor.h

Signed-off-by: Gabriela Bittencourt 
---
 drivers/staging/sm750fb/sm750_cursor.h | 17 +++--
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750_cursor.h 
b/drivers/staging/sm750fb/sm750_cursor.h
index 16ac07eb58d6..b59643dd61ed 100644
--- a/drivers/staging/sm750fb/sm750_cursor.h
+++ b/drivers/staging/sm750fb/sm750_cursor.h
@@ -5,14 +5,11 @@
 /* hw_cursor_xxx works for voyager,718 and 750 */
 void sm750_hw_cursor_enable(struct lynx_cursor *cursor);
 void sm750_hw_cursor_disable(struct lynx_cursor *cursor);
-void sm750_hw_cursor_setSize(struct lynx_cursor *cursor,
-   int w, int h);
-void sm750_hw_cursor_setPos(struct lynx_cursor *cursor,
-   int x, int y);
-void sm750_hw_cursor_setColor(struct lynx_cursor *cursor,
-   u32 fg, u32 bg);
-void sm750_hw_cursor_setData(struct lynx_cursor *cursor,
-   u16 rop, const u8 *data, const u8 *mask);
-void sm750_hw_cursor_setData2(struct lynx_cursor *cursor,
-   u16 rop, const u8 *data, const u8 *mask);
+void sm750_hw_cursor_setSize(struct lynx_cursor *cursor, int w, int h);
+void sm750_hw_cursor_setPos(struct lynx_cursor *cursor, int x, int y);
+void sm750_hw_cursor_setColor(struct lynx_cursor *cursor, u32 fg, u32 bg);
+void sm750_hw_cursor_setData(struct lynx_cursor *cursor, u16 rop,
+const u8 *data, const u8 *mask);
+void sm750_hw_cursor_setData2(struct lynx_cursor *cursor, u16 rop,
+ const u8 *data, const u8 *mask);
 #endif
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/3] staging: sm750fb: align arguments with open parenthesis in file sm750_accel.h

2019-10-24 Thread Gabriela Bittencourt
Cleans up checks of "Alignment should match open parenthesis"
in file sm750_accel.h

Signed-off-by: Gabriela Bittencourt 
---
 drivers/staging/sm750fb/sm750_accel.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750_accel.h 
b/drivers/staging/sm750fb/sm750_accel.h
index c16350b5a310..2c79cb730a0a 100644
--- a/drivers/staging/sm750fb/sm750_accel.h
+++ b/drivers/staging/sm750fb/sm750_accel.h
@@ -190,9 +190,9 @@ void sm750_hw_set2dformat(struct lynx_accel *accel, int 
fmt);
 void sm750_hw_de_init(struct lynx_accel *accel);
 
 int sm750_hw_fillrect(struct lynx_accel *accel,
-   u32 base, u32 pitch, u32 Bpp,
-   u32 x, u32 y, u32 width, u32 height,
-   u32 color, u32 rop);
+ u32 base, u32 pitch, u32 Bpp,
+ u32 x, u32 y, u32 width, u32 height,
+ u32 color, u32 rop);
 
 /**
  * sm750_hm_copyarea
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/3] staging: sm750fb: align arguments with open parenthesis in ddk750_sii164.c

2019-10-24 Thread Gabriela Bittencourt
Cleans up checks of "Alignment should match open parenthesis"
in file ddk750_sii164.c

Signed-off-by: Gabriela Bittencourt 
---
 drivers/staging/sm750fb/ddk750_sii164.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/sm750fb/ddk750_sii164.c 
b/drivers/staging/sm750fb/ddk750_sii164.c
index bee58edc84e7..73e0e9f41ec5 100644
--- a/drivers/staging/sm750fb/ddk750_sii164.c
+++ b/drivers/staging/sm750fb/ddk750_sii164.c
@@ -141,7 +141,7 @@ long sii164InitChip(unsigned char edge_select,
 
/* Check if SII164 Chip exists */
if ((sii164GetVendorID() == SII164_VENDOR_ID) &&
-   (sii164GetDeviceID() == SII164_DEVICE_ID)) {
+   (sii164GetDeviceID() == SII164_DEVICE_ID)) {
/*
 *  Initialize SII164 controller chip.
 */
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 0/3] staging: sm750fb: align arguments with open parenthesis

2019-10-24 Thread Gabriela Bittencourt
Cleans up checks of "Alignment should match open parenthesis"
in tree sm750fb

Gabriela Bittencourt (3):
  staging: sm750fb: align arguments with open parenthesis in
ddk750_sii164.c
  staging: sm750fb: align arguments with open parenthesis in file
sm750_accel.h
  staging: sm750fb: align arguments with open parenthesis in file
sm750_cursor.h

 drivers/staging/sm750fb/ddk750_sii164.c |  2 +-
 drivers/staging/sm750fb/sm750_accel.h   |  6 +++---
 drivers/staging/sm750fb/sm750_cursor.h  | 17 +++--
 3 files changed, 11 insertions(+), 14 deletions(-)

-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 15/15] staging: exfat: Clean up return codes - FFS_SUCCESS

2019-10-24 Thread Joe Perches
On Thu, 2019-10-24 at 11:53 -0400, Valdis Kletnieks wrote:
> Just replace FFS_SUCCESS with a literal 0.

[]

> diff --git a/drivers/staging/exfat/exfat_cache.c 
> b/drivers/staging/exfat/exfat_cache.c
[]
> @@ -214,7 +214,7 @@ static u8 *FAT_getblk(struct super_block *sb, sector_t 
> sec)
>  
>   FAT_cache_insert_hash(sb, bp);
>  
> - if (sector_read(sb, sec, >buf_bh, 1) != FFS_SUCCESS) {
> + if (sector_read(sb, sec, >buf_bh, 1) != 0) {

Probably nicer to just drop the != 0

> diff --git a/drivers/staging/exfat/exfat_super.c 
> b/drivers/staging/exfat/exfat_super.c
[]
> @@ -768,13 +768,13 @@ static int ffsReadFile(struct inode *inode, struct 
> file_id_t *fid, void *buffer,
>  
>   if ((offset == 0) && (oneblkread == p_bd->sector_size)) {
>   if (sector_read(sb, LogSector, _bh, 1) !=
> - FFS_SUCCESS)
> + 0)

especially for these split line tests


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 04/15] staging: exfat: Clean up return codes - FFS_PERMISSIONERR

2019-10-24 Thread Valdis Klētnieks
On Thu, 24 Oct 2019 09:23:33 -0700, Joe Perches said:
> On Thu, 2019-10-24 at 11:53 -0400, Valdis Kletnieks wrote:

> > if (err) {
> > -   if (err == FFS_PERMISSIONERR)
> > +   if (err == -EPERM)
> > err = -EPERM;
> > else if (err == FFS_INVALIDPATH)
> > err = -EINVAL;
>
> These test and assign to same value blocks look kinda silly.

One patch, one thing.  Those are getting cleaned up in a subsequent patch.:)


pgphGhdPGpvmR.pgp
Description: PGP signature
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 00/15] staging: exfat: Clean up return codes

2019-10-24 Thread Joe Perches
On Thu, 2019-10-24 at 11:53 -0400, Valdis Kletnieks wrote:
> The code had its own non-standard FFS_FOO return codes. Go through
> and convert them all the kernel standard -EFOO codes.
> 
> Valdis Kletnieks (15):
>   staging: exfat: Clean up return codes - FFS_FULL
>   staging: exfat: Clean up return codes - FFS_NOTFOUND
>   staging: exfat: Clean up return codes - FFS_DIRBUSY
>   staging: exfat: Clean up return codes - FFS_PERMISSIONERR
>   staging: exfat: Clean up return codes - FFS_NAMETOOLONG
>   staging: exfat: Clean up return codes - FFS_FILEEXIST
>   staging: exfat: Clean up return codes - FFS_INVALIDPATH
>   staging: exfat: Clean up return code - FFS_MEMORYERR
>   staging: exfat: Clean up return codes - FFS_FORMATERR
>   staging: exfat: Clean up return codes - FFS_MEDIAERR
>   staging: exfat: Clean up return codes - FFS_EOF
>   staging: exfat: Clean up return codes - FFS_INVALIDFID
>   staging: exfat: Clean up return codes - FFS_ERROR
>   staging: exfat: Clean up return codes - remove unused codes
>   staging: exfat: Clean up return codes - FFS_SUCCESS

All well and good, but does converting the error code from
positive to negative have any impact on any of the code
paths that use these return values?

if (error > 0)
vs
if (error < 0)

?

If you've gone through all the return tests,
then it would be nice to say so.


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: rtl8188eu: remove code valid only for 5 GHz

2019-10-24 Thread Michael Straube
Remove code valid only for 5 GHz, according to the TODO.

- find and remove remaining code valid only for 5 GHz. Most of the obvious
  ones have been removed, but things like channel > 14 still exist.

Signed-off-by: Michael Straube 
---
 drivers/staging/rtl8188eu/core/rtw_ap.c   | 12 ++--
 .../staging/rtl8188eu/os_dep/ioctl_linux.c| 30 +--
 2 files changed, 11 insertions(+), 31 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c 
b/drivers/staging/rtl8188eu/core/rtw_ap.c
index 9aa44c921aca..88e42cc1d837 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -440,15 +440,9 @@ static void update_bmc_sta(struct adapter *padapter)
tx_ra_bitmap |= 
rtw_get_bit_value_from_ieee_value(psta->bssrateset[i] & 0x7f);
}
 
-   if (pcur_network->Configuration.DSConfig > 14) {
-   /* force to A mode. 5G doesn't support CCK rates */
-   network_type = WIRELESS_11A;
-   tx_ra_bitmap = 0x150; /*  6, 12, 24 Mbps */
-   } else {
-   /* force to b mode */
-   network_type = WIRELESS_11B;
-   tx_ra_bitmap = 0xf;
-   }
+   /* force to b mode */
+   network_type = WIRELESS_11B;
+   tx_ra_bitmap = 0xf;
 
raid = networktype_to_raid(network_type);
init_rate = get_highest_rate_idx(tx_ra_bitmap & 0x0fff) & 
0x3f;
diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
index ec5835d1aa8c..710c33fd4965 100644
--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
@@ -148,17 +148,10 @@ static char *translate_scan(struct adapter *padapter,
else
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bg");
} else {
-   if (pnetwork->network.Configuration.DSConfig > 14) {
-   if (ht_cap)
-   snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11an");
-   else
-   snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11a");
-   } else {
-   if (ht_cap)
-   snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11gn");
-   else
-   snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11g");
-   }
+   if (ht_cap)
+   snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11gn");
+   else
+   snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11g");
}
 
start = iwe_stream_add_event(info, start, stop, , IW_EV_CHAR_LEN);
@@ -650,17 +643,10 @@ static int rtw_wx_get_name(struct net_device *dev,
else
snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bg");
} else {
-   if (pcur_bss->Configuration.DSConfig > 14) {
-   if (ht_cap)
-   snprintf(wrqu->name, IFNAMSIZ, "IEEE 
802.11an");
-   else
-   snprintf(wrqu->name, IFNAMSIZ, "IEEE 
802.11a");
-   } else {
-   if (ht_cap)
-   snprintf(wrqu->name, IFNAMSIZ, "IEEE 
802.11gn");
-   else
-   snprintf(wrqu->name, IFNAMSIZ, "IEEE 
802.11g");
-   }
+   if (ht_cap)
+   snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11gn");
+   else
+   snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11g");
}
} else {
snprintf(wrqu->name, IFNAMSIZ, "unassociated");
-- 
2.23.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 14/15] staging: exfat: Clean up return codes - remove unused codes

2019-10-24 Thread Valdis Kletnieks
There are 6 FFS_* error values not used at all. Remove them.

Signed-off-by: Valdis Kletnieks 
---
 drivers/staging/exfat/exfat.h | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index 2ca2710601ae..819a21d72c67 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -210,12 +210,6 @@ static inline u16 get_row_index(u16 i)
 
 /* return values */
 #define FFS_SUCCESS 0
-#define FFS_MOUNTED 3
-#define FFS_NOTMOUNTED  4
-#define FFS_ALIGNMENTERR5
-#define FFS_SEMAPHOREERR6
-#define FFS_NOTOPENED   12
-#define FFS_MAXOPENED   13
 
 #define NUM_UPCASE  2918
 
-- 
2.23.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 15/15] staging: exfat: Clean up return codes - FFS_SUCCESS

2019-10-24 Thread Valdis Kletnieks
Just replace FFS_SUCCESS with a literal 0.

Signed-off-by: Valdis Kletnieks 
---
 drivers/staging/exfat/exfat.h   |  3 -
 drivers/staging/exfat/exfat_cache.c |  4 +-
 drivers/staging/exfat/exfat_core.c  | 90 ++---
 drivers/staging/exfat/exfat_super.c | 50 
 4 files changed, 72 insertions(+), 75 deletions(-)

diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index 819a21d72c67..3532879ca73e 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -208,9 +208,6 @@ static inline u16 get_row_index(u16 i)
 #define FM_REGULAR  0x00
 #define FM_SYMLINK  0x40
 
-/* return values */
-#define FFS_SUCCESS 0
-
 #define NUM_UPCASE  2918
 
 #define DOS_CUR_DIR_NAME".  "
diff --git a/drivers/staging/exfat/exfat_cache.c 
b/drivers/staging/exfat/exfat_cache.c
index e9ad0353b4e5..44383cc1c937 100644
--- a/drivers/staging/exfat/exfat_cache.c
+++ b/drivers/staging/exfat/exfat_cache.c
@@ -214,7 +214,7 @@ static u8 *FAT_getblk(struct super_block *sb, sector_t sec)
 
FAT_cache_insert_hash(sb, bp);
 
-   if (sector_read(sb, sec, >buf_bh, 1) != FFS_SUCCESS) {
+   if (sector_read(sb, sec, >buf_bh, 1) != 0) {
FAT_cache_remove_hash(bp);
bp->drv = -1;
bp->sec = ~0;
@@ -583,7 +583,7 @@ static u8 *__buf_getblk(struct super_block *sb, sector_t 
sec)
 
buf_cache_insert_hash(sb, bp);
 
-   if (sector_read(sb, sec, >buf_bh, 1) != FFS_SUCCESS) {
+   if (sector_read(sb, sec, >buf_bh, 1) != 0) {
buf_cache_remove_hash(bp);
bp->drv = -1;
bp->sec = ~0;
diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index 7efc5d08cada..3d01d0b9941b 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -102,7 +102,7 @@ void fs_set_vol_flags(struct super_block *sb, u32 new_flag)
if (p_fs->vol_type == EXFAT) {
if (!p_fs->pbr_bh) {
if (sector_read(sb, p_fs->PBR_sector,
-   _fs->pbr_bh, 1) != FFS_SUCCESS)
+   _fs->pbr_bh, 1) != 0)
return;
}
 
@@ -184,7 +184,7 @@ s32 load_alloc_bitmap(struct super_block *sb)
for (j = 0; j < p_fs->map_sectors; j++) {
p_fs->vol_amap[j] = NULL;
ret = sector_read(sb, sector + j, 
&(p_fs->vol_amap[j]), 1);
-   if (ret != FFS_SUCCESS) {
+   if (ret != 0) {
/*  release all buffers and 
free vol_amap */
i = 0;
while (i < j)
@@ -197,7 +197,7 @@ s32 load_alloc_bitmap(struct super_block *sb)
}
 
p_fs->pbr_bh = NULL;
-   return FFS_SUCCESS;
+   return 0;
}
}
 
@@ -332,7 +332,7 @@ static void sync_alloc_bitmap(struct super_block *sb)
 static s32 clear_cluster(struct super_block *sb, u32 clu)
 {
sector_t s, n;
-   s32 ret = FFS_SUCCESS;
+   s32 ret = 0;
struct buffer_head *tmp_bh = NULL;
struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info);
struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info);
@@ -347,12 +347,12 @@ static s32 clear_cluster(struct super_block *sb, u32 clu)
 
for (; s < n; s++) {
ret = sector_read(sb, s, _bh, 0);
-   if (ret != FFS_SUCCESS)
+   if (ret != 0)
return ret;
 
memset((char *)tmp_bh->b_data, 0x0, p_bd->sector_size);
ret = sector_write(sb, s, tmp_bh, 0);
-   if (ret != FFS_SUCCESS)
+   if (ret != 0)
break;
}
 
@@ -390,7 +390,7 @@ static s32 exfat_alloc_cluster(struct super_block *sb, s32 
num_alloc,
}
}
 
-   if (set_alloc_bitmap(sb, new_clu - 2) != FFS_SUCCESS)
+   if (set_alloc_bitmap(sb, new_clu - 2) != 0)
return -EIO;
 
num_clusters++;
@@ -468,7 +468,7 @@ static void exfat_free_cluster(struct super_block *sb, 
struct chain_t *p_chain,
buf_release(sb, sector + i);
}
 
-   if (clr_alloc_bitmap(sb, clu - 2) != FFS_SUCCESS)
+   if (clr_alloc_bitmap(sb, clu - 2) != 0)
break;
clu++;
 
@@ -485,7 +485,7 @@ static void exfat_free_cluster(struct super_block *sb, 
struct chain_t 

[PATCH 13/15] staging: exfat: Clean up return codes - FFS_ERROR

2019-10-24 Thread Valdis Kletnieks
Convert FFS_ERROR to -EINVAL

Signed-off-by: Valdis Kletnieks 
---
 drivers/staging/exfat/exfat.h   |  1 -
 drivers/staging/exfat/exfat_core.c  |  8 
 drivers/staging/exfat/exfat_super.c | 20 ++--
 3 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index 505751bf1817..2ca2710601ae 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -216,7 +216,6 @@ static inline u16 get_row_index(u16 i)
 #define FFS_SEMAPHOREERR6
 #define FFS_NOTOPENED   12
 #define FFS_MAXOPENED   13
-#define FFS_ERROR   19
 
 #define NUM_UPCASE  2918
 
diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index 7e637a8e19d3..7efc5d08cada 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -587,7 +587,7 @@ void exfat_chain_cont_cluster(struct super_block *sb, u32 
chain, s32 len)
 static s32 __load_upcase_table(struct super_block *sb, sector_t sector,
   u32 num_sectors, u32 utbl_checksum)
 {
-   int i, ret = FFS_ERROR;
+   int i, ret = -EINVAL;
u32 j;
struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info);
struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info);
@@ -662,7 +662,7 @@ static s32 __load_upcase_table(struct super_block *sb, 
sector_t sector,
brelse(tmp_bh);
return FFS_SUCCESS;
}
-   ret = FFS_ERROR;
+   ret = -EINVAL;
 error:
if (tmp_bh)
brelse(tmp_bh);
@@ -672,7 +672,7 @@ static s32 __load_upcase_table(struct super_block *sb, 
sector_t sector,
 
 static s32 __load_default_upcase_table(struct super_block *sb)
 {
-   int i, ret = FFS_ERROR;
+   int i, ret = -EINVAL;
u32 j;
struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info);
 
@@ -847,7 +847,7 @@ static s32 __write_partial_entries_in_entry_set(struct 
super_block *sb,
return FFS_SUCCESS;
 err_out:
pr_debug("%s failed\n", __func__);
-   return FFS_ERROR;
+   return -EINVAL;
 }
 
 /* write back all entries in entry set */
diff --git a/drivers/staging/exfat/exfat_super.c 
b/drivers/staging/exfat/exfat_super.c
index 485297974ae7..0ce27a6babee 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -492,7 +492,7 @@ static int ffsGetVolInfo(struct super_block *sb, struct 
vol_info_t *info)
 
/* check the validity of pointer parameters */
if (!info)
-   return FFS_ERROR;
+   return -EINVAL;
 
/* acquire the lock for file system critical section */
down(_fs->v_sem);
@@ -555,7 +555,7 @@ static int ffsLookupFile(struct inode *inode, char *path, 
struct file_id_t *fid)
 
/* check the validity of pointer parameters */
if (!fid || !path || (*path == '\0'))
-   return FFS_ERROR;
+   return -EINVAL;
 
/* acquire the lock for file system critical section */
down(_fs->v_sem);
@@ -648,7 +648,7 @@ static int ffsCreateFile(struct inode *inode, char *path, 
u8 mode,
 
/* check the validity of pointer parameters */
if (!fid || !path || (*path == '\0'))
-   return FFS_ERROR;
+   return -EINVAL;
 
/* acquire the lock for file system critical section */
down(_fs->v_sem);
@@ -697,7 +697,7 @@ static int ffsReadFile(struct inode *inode, struct 
file_id_t *fid, void *buffer,
 
/* check the validity of pointer parameters */
if (!buffer)
-   return FFS_ERROR;
+   return -EINVAL;
 
/* acquire the lock for file system critical section */
down(_fs->v_sem);
@@ -827,7 +827,7 @@ static int ffsWriteFile(struct inode *inode, struct 
file_id_t *fid,
 
/* check the validity of pointer parameters */
if (!buffer)
-   return FFS_ERROR;
+   return -EINVAL;
 
/* acquire the lock for file system critical section */
down(_fs->v_sem);
@@ -1232,7 +1232,7 @@ static int ffsMoveFile(struct inode *old_parent_inode, 
struct file_id_t *fid,
 
/* check the validity of pointer parameters */
if (!new_path || (*new_path == '\0'))
-   return FFS_ERROR;
+   return -EINVAL;
 
/* acquire the lock for file system critical section */
down(_fs->v_sem);
@@ -1455,7 +1455,7 @@ static int ffsSetAttr(struct inode *inode, u32 attr)
if (p_fs->dev_ejected)
ret = -EIO;
else
-   ret = FFS_ERROR;
+   ret = -EINVAL;
 
if (p_fs->vol_type == EXFAT)
release_entry_set(es);
@@ -1747,7 +1747,7 @@ static int ffsMapCluster(struct inode *inode, s32 
clu_offset, u32 *clu)
 
/* check the validity of pointer parameters */
if 

[PATCH 08/15] staging: exfat: Clean up return code - FFS_MEMORYERR

2019-10-24 Thread Valdis Kletnieks
Convert FFS_MEMORYERR to -ENOMEM

Signed-off-by: Valdis Kletnieks 
---
 drivers/staging/exfat/exfat.h  |  1 -
 drivers/staging/exfat/exfat_core.c | 10 +-
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index 00e5e37100ce..2588a6cbe552 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -218,7 +218,6 @@ static inline u16 get_row_index(u16 i)
 #define FFS_NOTOPENED   12
 #define FFS_MAXOPENED   13
 #define FFS_EOF 15
-#define FFS_MEMORYERR   17
 #define FFS_ERROR   19
 
 #define NUM_UPCASE  2918
diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index 23c369fb98e5..fa2bf18b4a14 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -177,7 +177,7 @@ s32 load_alloc_bitmap(struct super_block *sb)
   sizeof(struct 
buffer_head *),
   GFP_KERNEL);
if (!p_fs->vol_amap)
-   return FFS_MEMORYERR;
+   return -ENOMEM;
 
sector = START_SECTOR(p_fs->map_clu);
 
@@ -604,7 +604,7 @@ static s32 __load_upcase_table(struct super_block *sb, 
sector_t sector,
upcase_table = p_fs->vol_utbl = kmalloc(UTBL_COL_COUNT * sizeof(u16 *),
GFP_KERNEL);
if (!upcase_table)
-   return FFS_MEMORYERR;
+   return -ENOMEM;
memset(upcase_table, 0, UTBL_COL_COUNT * sizeof(u16 *));
 
while (sector < end_sector) {
@@ -644,7 +644,7 @@ static s32 __load_upcase_table(struct super_block *sb, 
sector_t sector,
upcase_table[col_index] = 
kmalloc_array(UTBL_ROW_COUNT,
sizeof(u16), GFP_KERNEL);
if (!upcase_table[col_index]) {
-   ret = FFS_MEMORYERR;
+   ret = -ENOMEM;
goto error;
}
 
@@ -684,7 +684,7 @@ static s32 __load_default_upcase_table(struct super_block 
*sb)
upcase_table = p_fs->vol_utbl = kmalloc(UTBL_COL_COUNT * sizeof(u16 *),
GFP_KERNEL);
if (!upcase_table)
-   return FFS_MEMORYERR;
+   return -ENOMEM;
memset(upcase_table, 0, UTBL_COL_COUNT * sizeof(u16 *));
 
for (i = 0; index <= 0x && i < NUM_UPCASE * 2; i += 2) {
@@ -707,7 +707,7 @@ static s32 __load_default_upcase_table(struct super_block 
*sb)

sizeof(u16),

GFP_KERNEL);
if (!upcase_table[col_index]) {
-   ret = FFS_MEMORYERR;
+   ret = -ENOMEM;
goto error;
}
 
-- 
2.23.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 11/15] staging: exfat: Clean up return codes - FFS_EOF

2019-10-24 Thread Valdis Kletnieks
Convert FFS_EOF to return 0 for a zero-length read() as per 'man 2 read'.

Signed-off-by: Valdis Kletnieks 
---
 drivers/staging/exfat/exfat.h   | 1 -
 drivers/staging/exfat/exfat_super.c | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index df7b99707aed..3ff7293fedd2 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -217,7 +217,6 @@ static inline u16 get_row_index(u16 i)
 #define FFS_INVALIDFID  8
 #define FFS_NOTOPENED   12
 #define FFS_MAXOPENED   13
-#define FFS_EOF 15
 #define FFS_ERROR   19
 
 #define NUM_UPCASE  2918
diff --git a/drivers/staging/exfat/exfat_super.c 
b/drivers/staging/exfat/exfat_super.c
index a5c85dafefb4..a0c28fd8824b 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -717,7 +717,7 @@ static int ffsReadFile(struct inode *inode, struct 
file_id_t *fid, void *buffer,
if (count == 0) {
if (rcount)
*rcount = 0;
-   ret = FFS_EOF;
+   ret = 0;
goto out;
}
 
-- 
2.23.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 09/15] staging: exfat: Clean up return codes - FFS_FORMATERR

2019-10-24 Thread Valdis Kletnieks
Convert FFS_FORMATERR to -EFSCORRUPTED

Signed-off-by: Valdis Kletnieks 
---
 drivers/staging/exfat/exfat.h   | 3 ++-
 drivers/staging/exfat/exfat_core.c  | 4 ++--
 drivers/staging/exfat/exfat_super.c | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index 2588a6cbe552..7ca187e77cbe 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -30,6 +30,8 @@
 #undef DEBUG
 #endif
 
+#define EFSCORRUPTED   EUCLEAN /* Filesystem is corrupted */
+
 #define DENTRY_SIZE32  /* dir entry size */
 #define DENTRY_SIZE_BITS   5
 
@@ -209,7 +211,6 @@ static inline u16 get_row_index(u16 i)
 /* return values */
 #define FFS_SUCCESS 0
 #define FFS_MEDIAERR1
-#define FFS_FORMATERR   2
 #define FFS_MOUNTED 3
 #define FFS_NOTMOUNTED  4
 #define FFS_ALIGNMENTERR5
diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index fa2bf18b4a14..39c103e73b63 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -205,7 +205,7 @@ s32 load_alloc_bitmap(struct super_block *sb)
return FFS_MEDIAERR;
}
 
-   return FFS_FORMATERR;
+   return -EFSCORRUPTED;
 }
 
 void free_alloc_bitmap(struct super_block *sb)
@@ -2309,7 +2309,7 @@ s32 exfat_mount(struct super_block *sb, struct 
pbr_sector_t *p_pbr)
struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info);
 
if (p_bpb->num_fats == 0)
-   return FFS_FORMATERR;
+   return -EFSCORRUPTED;
 
p_fs->sectors_per_clu = 1 << p_bpb->sectors_per_clu_bits;
p_fs->sectors_per_clu_bits = p_bpb->sectors_per_clu_bits;
diff --git a/drivers/staging/exfat/exfat_super.c 
b/drivers/staging/exfat/exfat_super.c
index 5b35e3683605..161971c80c02 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -384,7 +384,7 @@ static int ffsMountVol(struct super_block *sb)
if (GET16_A(p_pbr->signature) != PBR_SIGNATURE) {
brelse(tmp_bh);
bdev_close(sb);
-   ret = FFS_FORMATERR;
+   ret = -EFSCORRUPTED;
goto out;
}
 
-- 
2.23.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 10/15] staging: exfat: Clean up return codes - FFS_MEDIAERR

2019-10-24 Thread Valdis Kletnieks
Convert FFS_MEDIAERR to (mostly) -ENOENT and -EIO.  Some additional code surgery
needed to propogate correct error codes upwards.

Signed-off-by: Valdis Kletnieks 
---
 drivers/staging/exfat/exfat.h|   1 -
 drivers/staging/exfat/exfat_blkdev.c |  18 ++---
 drivers/staging/exfat/exfat_core.c   |  68 
 drivers/staging/exfat/exfat_super.c  | 115 ++-
 4 files changed, 101 insertions(+), 101 deletions(-)

diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index 7ca187e77cbe..df7b99707aed 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -210,7 +210,6 @@ static inline u16 get_row_index(u16 i)
 
 /* return values */
 #define FFS_SUCCESS 0
-#define FFS_MEDIAERR1
 #define FFS_MOUNTED 3
 #define FFS_NOTMOUNTED  4
 #define FFS_ALIGNMENTERR5
diff --git a/drivers/staging/exfat/exfat_blkdev.c 
b/drivers/staging/exfat/exfat_blkdev.c
index 81d20e6241c6..0abae041f632 100644
--- a/drivers/staging/exfat/exfat_blkdev.c
+++ b/drivers/staging/exfat/exfat_blkdev.c
@@ -40,11 +40,11 @@ int bdev_read(struct super_block *sb, sector_t secno, 
struct buffer_head **bh,
long flags = sbi->debug_flags;
 
if (flags & EXFAT_DEBUGFLAGS_ERROR_RW)
-   return FFS_MEDIAERR;
+   return -EIO;
 #endif /* CONFIG_EXFAT_KERNEL_DEBUG */
 
if (!p_bd->opened)
-   return FFS_MEDIAERR;
+   return -ENODEV;
 
if (*bh)
__brelse(*bh);
@@ -62,7 +62,7 @@ int bdev_read(struct super_block *sb, sector_t secno, struct 
buffer_head **bh,
WARN(!p_fs->dev_ejected,
 "[EXFAT] No bh, device seems wrong or to be ejected.\n");
 
-   return FFS_MEDIAERR;
+   return -EIO;
 }
 
 int bdev_write(struct super_block *sb, sector_t secno, struct buffer_head *bh,
@@ -77,11 +77,11 @@ int bdev_write(struct super_block *sb, sector_t secno, 
struct buffer_head *bh,
long flags = sbi->debug_flags;
 
if (flags & EXFAT_DEBUGFLAGS_ERROR_RW)
-   return FFS_MEDIAERR;
+   return -EIO;
 #endif /* CONFIG_EXFAT_KERNEL_DEBUG */
 
if (!p_bd->opened)
-   return FFS_MEDIAERR;
+   return -ENODEV;
 
if (secno == bh->b_blocknr) {
lock_buffer(bh);
@@ -89,7 +89,7 @@ int bdev_write(struct super_block *sb, sector_t secno, struct 
buffer_head *bh,
mark_buffer_dirty(bh);
unlock_buffer(bh);
if (sync && (sync_dirty_buffer(bh) != 0))
-   return FFS_MEDIAERR;
+   return -EIO;
} else {
count = num_secs << p_bd->sector_size_bits;
 
@@ -115,7 +115,7 @@ int bdev_write(struct super_block *sb, sector_t secno, 
struct buffer_head *bh,
WARN(!p_fs->dev_ejected,
 "[EXFAT] No bh, device seems wrong or to be ejected.\n");
 
-   return FFS_MEDIAERR;
+   return -EIO;
 }
 
 int bdev_sync(struct super_block *sb)
@@ -126,11 +126,11 @@ int bdev_sync(struct super_block *sb)
long flags = sbi->debug_flags;
 
if (flags & EXFAT_DEBUGFLAGS_ERROR_RW)
-   return FFS_MEDIAERR;
+   return -EIO;
 #endif /* CONFIG_EXFAT_KERNEL_DEBUG */
 
if (!p_bd->opened)
-   return FFS_MEDIAERR;
+   return -ENODEV;
 
return sync_blockdev(sb->s_bdev);
 }
diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index 39c103e73b63..7e637a8e19d3 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -158,7 +158,7 @@ s32 load_alloc_bitmap(struct super_block *sb)
ep = (struct bmap_dentry_t *)get_entry_in_dir(sb, ,
  i, NULL);
if (!ep)
-   return FFS_MEDIAERR;
+   return -ENOENT;
 
type = p_fs->fs_func->get_entry_type((struct dentry_t 
*)ep);
 
@@ -202,7 +202,7 @@ s32 load_alloc_bitmap(struct super_block *sb)
}
 
if (FAT_read(sb, clu.dir, ) != 0)
-   return FFS_MEDIAERR;
+   return -EIO;
}
 
return -EFSCORRUPTED;
@@ -391,13 +391,13 @@ static s32 exfat_alloc_cluster(struct super_block *sb, 
s32 num_alloc,
}
 
if (set_alloc_bitmap(sb, new_clu - 2) != FFS_SUCCESS)
-   return -1;
+   return -EIO;
 
num_clusters++;
 
if (p_chain->flags == 0x01) {
if (FAT_write(sb, new_clu, CLUSTER_32(~0)) < 0)
-   return -1;
+   return -EIO;
}
 
if (p_chain->dir == CLUSTER_32(~0)) {
@@ -405,7 +405,7 @@ static s32 exfat_alloc_cluster(struct 

[PATCH 04/15] staging: exfat: Clean up return codes - FFS_PERMISSIONERR

2019-10-24 Thread Valdis Kletnieks
Convert FFS_PERMISSIONERR to -EPERM

Signed-off-by: Valdis Kletnieks 
---
 drivers/staging/exfat/exfat.h   |  1 -
 drivers/staging/exfat/exfat_super.c | 20 ++--
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index ec52237b01cd..86bdcf222a5a 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -217,7 +217,6 @@ static inline u16 get_row_index(u16 i)
 #define FFS_INVALIDPATH 7
 #define FFS_INVALIDFID  8
 #define FFS_FILEEXIST   10
-#define FFS_PERMISSIONERR   11
 #define FFS_NOTOPENED   12
 #define FFS_MAXOPENED   13
 #define FFS_EOF 15
diff --git a/drivers/staging/exfat/exfat_super.c 
b/drivers/staging/exfat/exfat_super.c
index 566cfba0a522..fd5d8ba0d8bc 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -702,7 +702,7 @@ static int ffsReadFile(struct inode *inode, struct 
file_id_t *fid, void *buffer,
 
/* check if the given file ID is opened */
if (fid->type != TYPE_FILE) {
-   ret = FFS_PERMISSIONERR;
+   ret = -EPERM;
goto out;
}
 
@@ -832,7 +832,7 @@ static int ffsWriteFile(struct inode *inode, struct 
file_id_t *fid,
 
/* check if the given file ID is opened */
if (fid->type != TYPE_FILE) {
-   ret = FFS_PERMISSIONERR;
+   ret = -EPERM;
goto out;
}
 
@@ -1079,7 +1079,7 @@ static int ffsTruncateFile(struct inode *inode, u64 
old_size, u64 new_size)
 
/* check if the given file ID is opened */
if (fid->type != TYPE_FILE) {
-   ret = FFS_PERMISSIONERR;
+   ret = -EPERM;
goto out;
}
 
@@ -1246,7 +1246,7 @@ static int ffsMoveFile(struct inode *old_parent_inode, 
struct file_id_t *fid,
/* check if the old file is "." or ".." */
if (p_fs->vol_type != EXFAT) {
if ((olddir.dir != p_fs->root_dir) && (dentry < 2)) {
-   ret = FFS_PERMISSIONERR;
+   ret = -EPERM;
goto out2;
}
}
@@ -1258,7 +1258,7 @@ static int ffsMoveFile(struct inode *old_parent_inode, 
struct file_id_t *fid,
}
 
if (p_fs->fs_func->get_entry_attr(ep) & ATTR_READONLY) {
-   ret = FFS_PERMISSIONERR;
+   ret = -EPERM;
goto out2;
}
 
@@ -1365,7 +1365,7 @@ static int ffsRemoveFile(struct inode *inode, struct 
file_id_t *fid)
}
 
if (p_fs->fs_func->get_entry_attr(ep) & ATTR_READONLY) {
-   ret = FFS_PERMISSIONERR;
+   ret = -EPERM;
goto out;
}
fs_set_vol_flags(sb, VOL_DIRTY);
@@ -1947,7 +1947,7 @@ static int ffsReadDir(struct inode *inode, struct 
dir_entry_t *dir_entry)
 
/* check if the given file ID is opened */
if (fid->type != TYPE_DIR)
-   return FFS_PERMISSIONERR;
+   return -EPERM;
 
/* acquire the lock for file system critical section */
down(_fs->v_sem);
@@ -2145,7 +2145,7 @@ static int ffsRemoveDir(struct inode *inode, struct 
file_id_t *fid)
/* check if the file is "." or ".." */
if (p_fs->vol_type != EXFAT) {
if ((dir.dir != p_fs->root_dir) && (dentry < 2))
-   return FFS_PERMISSIONERR;
+   return -EPERM;
}
 
/* acquire the lock for file system critical section */
@@ -2526,7 +2526,7 @@ static int exfat_unlink(struct inode *dir, struct dentry 
*dentry)
 
err = ffsRemoveFile(dir, &(EXFAT_I(inode)->fid));
if (err) {
-   if (err == FFS_PERMISSIONERR)
+   if (err == -EPERM)
err = -EPERM;
else
err = -EIO;
@@ -2746,7 +2746,7 @@ static int exfat_rename(struct inode *old_dir, struct 
dentry *old_dentry,
err = ffsMoveFile(old_dir, &(EXFAT_I(old_inode)->fid), new_dir,
  new_dentry);
if (err) {
-   if (err == FFS_PERMISSIONERR)
+   if (err == -EPERM)
err = -EPERM;
else if (err == FFS_INVALIDPATH)
err = -EINVAL;
-- 
2.23.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 12/15] staging: exfat: Clean up return codes - FFS_INVALIDFID

2019-10-24 Thread Valdis Kletnieks
Covert FFS_INVALIDFID to -EINVAL

Signed-off-by: Valdis Kletnieks 
---
 drivers/staging/exfat/exfat.h   |  1 -
 drivers/staging/exfat/exfat_super.c | 10 +-
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index 3ff7293fedd2..505751bf1817 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -214,7 +214,6 @@ static inline u16 get_row_index(u16 i)
 #define FFS_NOTMOUNTED  4
 #define FFS_ALIGNMENTERR5
 #define FFS_SEMAPHOREERR6
-#define FFS_INVALIDFID  8
 #define FFS_NOTOPENED   12
 #define FFS_MAXOPENED   13
 #define FFS_ERROR   19
diff --git a/drivers/staging/exfat/exfat_super.c 
b/drivers/staging/exfat/exfat_super.c
index a0c28fd8824b..485297974ae7 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -693,7 +693,7 @@ static int ffsReadFile(struct inode *inode, struct 
file_id_t *fid, void *buffer,
 
/* check the validity of the given file id */
if (!fid)
-   return FFS_INVALIDFID;
+   return -EINVAL;
 
/* check the validity of pointer parameters */
if (!buffer)
@@ -823,7 +823,7 @@ static int ffsWriteFile(struct inode *inode, struct 
file_id_t *fid,
 
/* check the validity of the given file id */
if (!fid)
-   return FFS_INVALIDFID;
+   return -EINVAL;
 
/* check the validity of pointer parameters */
if (!buffer)
@@ -1228,7 +1228,7 @@ static int ffsMoveFile(struct inode *old_parent_inode, 
struct file_id_t *fid,
 
/* check the validity of the given file id */
if (!fid)
-   return FFS_INVALIDFID;
+   return -EINVAL;
 
/* check the validity of pointer parameters */
if (!new_path || (*new_path == '\0'))
@@ -1349,7 +1349,7 @@ static int ffsRemoveFile(struct inode *inode, struct 
file_id_t *fid)
 
/* check the validity of the given file id */
if (!fid)
-   return FFS_INVALIDFID;
+   return -EINVAL;
 
/* acquire the lock for file system critical section */
down(_fs->v_sem);
@@ -2136,7 +2136,7 @@ static int ffsRemoveDir(struct inode *inode, struct 
file_id_t *fid)
 
/* check the validity of the given file id */
if (!fid)
-   return FFS_INVALIDFID;
+   return -EINVAL;
 
dir.dir = fid->dir.dir;
dir.size = fid->dir.size;
-- 
2.23.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 06/15] staging: exfat: Clean up return codes - FFS_FILEEXIST

2019-10-24 Thread Valdis Kletnieks
Convert FFS_FILEEXIST to -EEXIST

Signed-off-by: Valdis Kletnieks 
---
 drivers/staging/exfat/exfat.h   |  1 -
 drivers/staging/exfat/exfat_core.c  |  2 +-
 drivers/staging/exfat/exfat_super.c | 14 +++---
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index a2b865788697..c56363652c5d 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -216,7 +216,6 @@ static inline u16 get_row_index(u16 i)
 #define FFS_SEMAPHOREERR6
 #define FFS_INVALIDPATH 7
 #define FFS_INVALIDFID  8
-#define FFS_FILEEXIST   10
 #define FFS_NOTOPENED   12
 #define FFS_MAXOPENED   13
 #define FFS_EOF 15
diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index af1ccd686e01..ba5680123b0f 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -2103,7 +2103,7 @@ static s32 fat_generate_dos_name(struct super_block *sb, 
struct chain_t *p_dir,
}
 
if ((count == 0) || (count >= 1024))
-   return FFS_FILEEXIST;
+   return -EEXIST;
fat_attach_count_to_dos_name(p_dosname->name, count);
 
/* Now dos_name has DOS~.EXT */
diff --git a/drivers/staging/exfat/exfat_super.c 
b/drivers/staging/exfat/exfat_super.c
index eb3c3642abca..2c294e238d7b 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -1288,7 +1288,7 @@ static int ffsMoveFile(struct inode *old_parent_inode, 
struct file_id_t *fid,
new_clu.flags = new_fid->flags;
 
if (!is_dir_empty(sb, _clu)) {
-   ret = FFS_FILEEXIST;
+   ret = -EEXIST;
goto out;
}
}
@@ -2156,7 +2156,7 @@ static int ffsRemoveDir(struct inode *inode, struct 
file_id_t *fid)
clu_to_free.flags = fid->flags;
 
if (!is_dir_empty(sb, _to_free)) {
-   ret = FFS_FILEEXIST;
+   ret = -EEXIST;
goto out;
}
 
@@ -2358,7 +2358,7 @@ static int exfat_create(struct inode *dir, struct dentry 
*dentry, umode_t mode,
if (err) {
if (err == FFS_INVALIDPATH)
err = -EINVAL;
-   else if (err == FFS_FILEEXIST)
+   else if (err == -EEXIST)
err = -EEXIST;
else if (err == -ENOSPC)
err = -ENOSPC;
@@ -2569,7 +2569,7 @@ static int exfat_symlink(struct inode *dir, struct dentry 
*dentry,
if (err) {
if (err == FFS_INVALIDPATH)
err = -EINVAL;
-   else if (err == FFS_FILEEXIST)
+   else if (err == -EEXIST)
err = -EEXIST;
else if (err == -ENOSPC)
err = -ENOSPC;
@@ -2639,7 +2639,7 @@ static int exfat_mkdir(struct inode *dir, struct dentry 
*dentry, umode_t mode)
if (err) {
if (err == FFS_INVALIDPATH)
err = -EINVAL;
-   else if (err == FFS_FILEEXIST)
+   else if (err == -EEXIST)
err = -EEXIST;
else if (err == -ENOSPC)
err = -ENOSPC;
@@ -2693,7 +2693,7 @@ static int exfat_rmdir(struct inode *dir, struct dentry 
*dentry)
if (err) {
if (err == FFS_INVALIDPATH)
err = -EINVAL;
-   else if (err == FFS_FILEEXIST)
+   else if (err == -EEXIST)
err = -ENOTEMPTY;
else if (err == -ENOENT)
err = -ENOENT;
@@ -2750,7 +2750,7 @@ static int exfat_rename(struct inode *old_dir, struct 
dentry *old_dentry,
err = -EPERM;
else if (err == FFS_INVALIDPATH)
err = -EINVAL;
-   else if (err == FFS_FILEEXIST)
+   else if (err == -EEXIST)
err = -EEXIST;
else if (err == -ENOENT)
err = -ENOENT;
-- 
2.23.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 05/15] staging: exfat: Clean up return codes - FFS_NAMETOOLONG

2019-10-24 Thread Valdis Kletnieks
Convert FFS_NOTNAMETOOLONG to -ENAMETOOLONG

Signed-off-by: Valdis Kletnieks 
---
 drivers/staging/exfat/exfat.h   | 1 -
 drivers/staging/exfat/exfat_super.c | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index 86bdcf222a5a..a2b865788697 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -221,7 +221,6 @@ static inline u16 get_row_index(u16 i)
 #define FFS_MAXOPENED   13
 #define FFS_EOF 15
 #define FFS_MEMORYERR   17
-#define FFS_NAMETOOLONG18
 #define FFS_ERROR   19
 
 #define NUM_UPCASE  2918
diff --git a/drivers/staging/exfat/exfat_super.c 
b/drivers/staging/exfat/exfat_super.c
index fd5d8ba0d8bc..eb3c3642abca 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -2362,7 +2362,7 @@ static int exfat_create(struct inode *dir, struct dentry 
*dentry, umode_t mode,
err = -EEXIST;
else if (err == -ENOSPC)
err = -ENOSPC;
-   else if (err == FFS_NAMETOOLONG)
+   else if (err == -ENAMETOOLONG)
err = -ENAMETOOLONG;
else
err = -EIO;
@@ -2643,7 +2643,7 @@ static int exfat_mkdir(struct inode *dir, struct dentry 
*dentry, umode_t mode)
err = -EEXIST;
else if (err == -ENOSPC)
err = -ENOSPC;
-   else if (err == FFS_NAMETOOLONG)
+   else if (err == -ENAMETOOLONG)
err = -ENAMETOOLONG;
else
err = -EIO;
-- 
2.23.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 02/15] staging: exfat: Clean up return codes - FFS_NOTFOUND

2019-10-24 Thread Valdis Kletnieks
Convert FFS_NOTFOUND to -ENOENT

Signed-off-by: Valdis Kletnieks 
---
 drivers/staging/exfat/exfat.h   | 1 -
 drivers/staging/exfat/exfat_super.c | 6 +++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index 4aca4ae44a98..1d82de4e1a5c 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -216,7 +216,6 @@ static inline u16 get_row_index(u16 i)
 #define FFS_SEMAPHOREERR6
 #define FFS_INVALIDPATH 7
 #define FFS_INVALIDFID  8
-#define FFS_NOTFOUND9
 #define FFS_FILEEXIST   10
 #define FFS_PERMISSIONERR   11
 #define FFS_NOTOPENED   12
diff --git a/drivers/staging/exfat/exfat_super.c 
b/drivers/staging/exfat/exfat_super.c
index 273fe2310e76..50fc097ded69 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -572,7 +572,7 @@ static int ffsLookupFile(struct inode *inode, char *path, 
struct file_id_t *fid)
dentry = p_fs->fs_func->find_dir_entry(sb, , _name, num_entries,
   _name, TYPE_ALL);
if (dentry < -1) {
-   ret = FFS_NOTFOUND;
+   ret = -ENOENT;
goto out;
}
 
@@ -2695,7 +2695,7 @@ static int exfat_rmdir(struct inode *dir, struct dentry 
*dentry)
err = -EINVAL;
else if (err == FFS_FILEEXIST)
err = -ENOTEMPTY;
-   else if (err == FFS_NOTFOUND)
+   else if (err == -ENOENT)
err = -ENOENT;
else if (err == FFS_DIRBUSY)
err = -EBUSY;
@@ -2752,7 +2752,7 @@ static int exfat_rename(struct inode *old_dir, struct 
dentry *old_dentry,
err = -EINVAL;
else if (err == FFS_FILEEXIST)
err = -EEXIST;
-   else if (err == FFS_NOTFOUND)
+   else if (err == -ENOENT)
err = -ENOENT;
else if (err == -ENOSPC)
err = -ENOSPC;
-- 
2.23.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 07/15] staging: exfat: Clean up return codes - FFS_INVALIDPATH

2019-10-24 Thread Valdis Kletnieks
Convert FFS_INVALIDPATH to -EINVAL

Signed-off-by: Valdis Kletnieks 
---
 drivers/staging/exfat/exfat.h   |  1 -
 drivers/staging/exfat/exfat_core.c  | 10 +-
 drivers/staging/exfat/exfat_super.c | 10 +-
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index c56363652c5d..00e5e37100ce 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -214,7 +214,6 @@ static inline u16 get_row_index(u16 i)
 #define FFS_NOTMOUNTED  4
 #define FFS_ALIGNMENTERR5
 #define FFS_SEMAPHOREERR6
-#define FFS_INVALIDPATH 7
 #define FFS_INVALIDFID  8
 #define FFS_NOTOPENED   12
 #define FFS_MAXOPENED   13
diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index ba5680123b0f..23c369fb98e5 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -2124,7 +2124,7 @@ s32 get_num_entries_and_dos_name(struct super_block *sb, 
struct chain_t *p_dir,
 
num_entries = p_fs->fs_func->calc_num_entries(p_uniname);
if (num_entries == 0)
-   return FFS_INVALIDPATH;
+   return -EINVAL;
 
if (p_fs->vol_type != EXFAT) {
nls_uniname_to_dosname(sb, p_dosname, p_uniname, );
@@ -2136,7 +2136,7 @@ s32 get_num_entries_and_dos_name(struct super_block *sb, 
struct chain_t *p_dir,
} else {
for (r = reserved_names; *r; r++) {
if (!strncmp((void *)p_dosname->name, *r, 8))
-   return FFS_INVALIDPATH;
+   return -EINVAL;
}
 
if (p_dosname->name_case != 0xFF)
@@ -2257,11 +2257,11 @@ s32 resolve_path(struct inode *inode, char *path, 
struct chain_t *p_dir,
struct file_id_t *fid = &(EXFAT_I(inode)->fid);
 
if (strscpy(name_buf, path, sizeof(name_buf)) < 0)
-   return FFS_INVALIDPATH;
+   return -EINVAL;
 
nls_cstring_to_uniname(sb, p_uniname, name_buf, );
if (lossy)
-   return FFS_INVALIDPATH;
+   return -EINVAL;
 
fid->size = i_size_read(inode);
 
@@ -2659,7 +2659,7 @@ s32 move_file(struct inode *inode, struct chain_t 
*p_olddir, s32 oldentry,
/* check if the source and target directory is the same */
if (fs_func->get_entry_type(epmov) == TYPE_DIR &&
fs_func->get_entry_clu0(epmov) == p_newdir->dir)
-   return FFS_INVALIDPATH;
+   return -EINVAL;
 
buf_lock(sb, sector_mov);
 
diff --git a/drivers/staging/exfat/exfat_super.c 
b/drivers/staging/exfat/exfat_super.c
index 2c294e238d7b..5b35e3683605 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -2356,7 +2356,7 @@ static int exfat_create(struct inode *dir, struct dentry 
*dentry, umode_t mode,
 
err = ffsCreateFile(dir, (u8 *)dentry->d_name.name, FM_REGULAR, );
if (err) {
-   if (err == FFS_INVALIDPATH)
+   if (err == -EINVAL)
err = -EINVAL;
else if (err == -EEXIST)
err = -EEXIST;
@@ -2567,7 +2567,7 @@ static int exfat_symlink(struct inode *dir, struct dentry 
*dentry,
 
err = ffsCreateFile(dir, (u8 *)dentry->d_name.name, FM_SYMLINK, );
if (err) {
-   if (err == FFS_INVALIDPATH)
+   if (err == -EINVAL)
err = -EINVAL;
else if (err == -EEXIST)
err = -EEXIST;
@@ -2637,7 +2637,7 @@ static int exfat_mkdir(struct inode *dir, struct dentry 
*dentry, umode_t mode)
 
err = ffsCreateDir(dir, (u8 *)dentry->d_name.name, );
if (err) {
-   if (err == FFS_INVALIDPATH)
+   if (err == -EINVAL)
err = -EINVAL;
else if (err == -EEXIST)
err = -EEXIST;
@@ -2691,7 +2691,7 @@ static int exfat_rmdir(struct inode *dir, struct dentry 
*dentry)
 
err = ffsRemoveDir(dir, &(EXFAT_I(inode)->fid));
if (err) {
-   if (err == FFS_INVALIDPATH)
+   if (err == -EINVAL)
err = -EINVAL;
else if (err == -EEXIST)
err = -ENOTEMPTY;
@@ -2748,7 +2748,7 @@ static int exfat_rename(struct inode *old_dir, struct 
dentry *old_dentry,
if (err) {
if (err == -EPERM)
err = -EPERM;
-   else if (err == FFS_INVALIDPATH)
+   else if (err == -EINVAL)
err = -EINVAL;
else if (err == -EEXIST)
err = -EEXIST;
-- 
2.23.0

___
devel mailing list
de...@linuxdriverproject.org

[PATCH 03/15] staging: exfat: Clean up return codes - FFS_DIRBUSY

2019-10-24 Thread Valdis Kletnieks
Convert FFS_DIRBUSY to -EBUSY

Signed-off-by: Valdis Kletnieks 
---
 drivers/staging/exfat/exfat.h   | 1 -
 drivers/staging/exfat/exfat_super.c | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index 1d82de4e1a5c..ec52237b01cd 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -221,7 +221,6 @@ static inline u16 get_row_index(u16 i)
 #define FFS_NOTOPENED   12
 #define FFS_MAXOPENED   13
 #define FFS_EOF 15
-#define FFS_DIRBUSY 16
 #define FFS_MEMORYERR   17
 #define FFS_NAMETOOLONG18
 #define FFS_ERROR   19
diff --git a/drivers/staging/exfat/exfat_super.c 
b/drivers/staging/exfat/exfat_super.c
index 50fc097ded69..566cfba0a522 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -2697,7 +2697,7 @@ static int exfat_rmdir(struct inode *dir, struct dentry 
*dentry)
err = -ENOTEMPTY;
else if (err == -ENOENT)
err = -ENOENT;
-   else if (err == FFS_DIRBUSY)
+   else if (err == -EBUSY)
err = -EBUSY;
else
err = -EIO;
-- 
2.23.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 01/15] staging: exfat: Clean up return codes - FFS_FULL

2019-10-24 Thread Valdis Kletnieks
Start cleaning up the odd scheme of return codes, starting with FFS_FULL

Signed-off-by: Valdis Kletnieks 
---
 drivers/staging/exfat/exfat.h   |  1 -
 drivers/staging/exfat/exfat_core.c  | 10 +-
 drivers/staging/exfat/exfat_super.c | 16 
 3 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
index 8738e41dd5a5..4aca4ae44a98 100644
--- a/drivers/staging/exfat/exfat.h
+++ b/drivers/staging/exfat/exfat.h
@@ -221,7 +221,6 @@ static inline u16 get_row_index(u16 i)
 #define FFS_PERMISSIONERR   11
 #define FFS_NOTOPENED   12
 #define FFS_MAXOPENED   13
-#define FFS_FULL14
 #define FFS_EOF 15
 #define FFS_DIRBUSY 16
 #define FFS_MEMORYERR   17
diff --git a/drivers/staging/exfat/exfat_core.c 
b/drivers/staging/exfat/exfat_core.c
index 7332e69fcbcd..af1ccd686e01 100644
--- a/drivers/staging/exfat/exfat_core.c
+++ b/drivers/staging/exfat/exfat_core.c
@@ -2369,7 +2369,7 @@ s32 create_dir(struct inode *inode, struct chain_t *p_dir,
/* find_empty_entry must be called before alloc_cluster */
dentry = find_empty_entry(inode, p_dir, num_entries);
if (dentry < 0)
-   return FFS_FULL;
+   return -ENOSPC;
 
clu.dir = CLUSTER_32(~0);
clu.size = 0;
@@ -2380,7 +2380,7 @@ s32 create_dir(struct inode *inode, struct chain_t *p_dir,
if (ret < 0)
return FFS_MEDIAERR;
else if (ret == 0)
-   return FFS_FULL;
+   return -ENOSPC;
 
ret = clear_cluster(sb, clu.dir);
if (ret != FFS_SUCCESS)
@@ -2472,7 +2472,7 @@ s32 create_file(struct inode *inode, struct chain_t 
*p_dir,
/* find_empty_entry must be called before alloc_cluster() */
dentry = find_empty_entry(inode, p_dir, num_entries);
if (dentry < 0)
-   return FFS_FULL;
+   return -ENOSPC;
 
/* (1) update the directory entry */
/* fill the dos name directory entry information of the created file.
@@ -2571,7 +2571,7 @@ s32 rename_file(struct inode *inode, struct chain_t 
*p_dir, s32 oldentry,
newentry = find_empty_entry(inode, p_dir, num_new_entries);
if (newentry < 0) {
buf_unlock(sb, sector_old);
-   return FFS_FULL;
+   return -ENOSPC;
}
 
epnew = get_entry_in_dir(sb, p_dir, newentry, _new);
@@ -2682,7 +2682,7 @@ s32 move_file(struct inode *inode, struct chain_t 
*p_olddir, s32 oldentry,
newentry = find_empty_entry(inode, p_newdir, num_new_entries);
if (newentry < 0) {
buf_unlock(sb, sector_mov);
-   return FFS_FULL;
+   return -ENOSPC;
}
 
epnew = get_entry_in_dir(sb, p_newdir, newentry, _new);
diff --git a/drivers/staging/exfat/exfat_super.c 
b/drivers/staging/exfat/exfat_super.c
index 0264be92c2be..273fe2310e76 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -1045,7 +1045,7 @@ static int ffsWriteFile(struct inode *inode, struct 
file_id_t *fid,
*wcount = write_bytes;
 
if (num_alloced == 0)
-   ret = FFS_FULL;
+   ret = -ENOSPC;
 
else if (p_fs->dev_ejected)
ret = FFS_MEDIAERR;
@@ -1801,7 +1801,7 @@ static int ffsMapCluster(struct inode *inode, s32 
clu_offset, u32 *clu)
ret = FFS_MEDIAERR;
goto out;
} else if (num_alloced == 0) {
-   ret = FFS_FULL;
+   ret = -ENOSPC;
goto out;
}
 
@@ -2360,7 +2360,7 @@ static int exfat_create(struct inode *dir, struct dentry 
*dentry, umode_t mode,
err = -EINVAL;
else if (err == FFS_FILEEXIST)
err = -EEXIST;
-   else if (err == FFS_FULL)
+   else if (err == -ENOSPC)
err = -ENOSPC;
else if (err == FFS_NAMETOOLONG)
err = -ENAMETOOLONG;
@@ -2571,7 +2571,7 @@ static int exfat_symlink(struct inode *dir, struct dentry 
*dentry,
err = -EINVAL;
else if (err == FFS_FILEEXIST)
err = -EEXIST;
-   else if (err == FFS_FULL)
+   else if (err == -ENOSPC)
err = -ENOSPC;
else
err = -EIO;
@@ -2583,7 +2583,7 @@ static int exfat_symlink(struct inode *dir, struct dentry 
*dentry,
if (err) {
ffsRemoveFile(dir, );
 
-   if (err == FFS_FULL)
+   if (err == -ENOSPC)
err = -ENOSPC;
else
err = -EIO;
@@ -2641,7 +2641,7 @@ static int 

[PATCH 00/15] staging: exfat: Clean up return codes

2019-10-24 Thread Valdis Kletnieks
The code had its own non-standard FFS_FOO return codes. Go through
and convert them all the kernel standard -EFOO codes.

Valdis Kletnieks (15):
  staging: exfat: Clean up return codes - FFS_FULL
  staging: exfat: Clean up return codes - FFS_NOTFOUND
  staging: exfat: Clean up return codes - FFS_DIRBUSY
  staging: exfat: Clean up return codes - FFS_PERMISSIONERR
  staging: exfat: Clean up return codes - FFS_NAMETOOLONG
  staging: exfat: Clean up return codes - FFS_FILEEXIST
  staging: exfat: Clean up return codes - FFS_INVALIDPATH
  staging: exfat: Clean up return code - FFS_MEMORYERR
  staging: exfat: Clean up return codes - FFS_FORMATERR
  staging: exfat: Clean up return codes - FFS_MEDIAERR
  staging: exfat: Clean up return codes - FFS_EOF
  staging: exfat: Clean up return codes - FFS_INVALIDFID
  staging: exfat: Clean up return codes - FFS_ERROR
  staging: exfat: Clean up return codes - remove unused codes
  staging: exfat: Clean up return codes - FFS_SUCCESS

 drivers/staging/exfat/exfat.h|  24 +--
 drivers/staging/exfat/exfat_blkdev.c |  18 +-
 drivers/staging/exfat/exfat_cache.c  |   4 +-
 drivers/staging/exfat/exfat_core.c   | 202 ++--
 drivers/staging/exfat/exfat_super.c  | 269 ++-
 5 files changed, 249 insertions(+), 268 deletions(-)

-- 
2.23.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RFC v1 00/12] mm: Don't mark hotplugged pages PG_reserved (including ZONE_DEVICE)

2019-10-24 Thread David Hildenbrand

On 23.10.19 09:26, David Hildenbrand wrote:

On 22.10.19 23:54, Dan Williams wrote:

Hi David,

Thanks for tackling this!


Thanks for having a look :)

[...]



I am probably a little bit too careful (but I don't want to break things).
In most places (besides KVM and vfio that are nuts), the
pfn_to_online_page() check could most probably be avoided by a
is_zone_device_page() check. However, I usually get suspicious when I see
a pfn_valid() check (especially after I learned that people mmap parts of
/dev/mem into user space, including memory without memmaps. Also, people
could memmap offline memory blocks this way :/). As long as this does not
hurt performance, I think we should rather do it the clean way.


I'm concerned about using is_zone_device_page() in places that are not
known to already have a reference to the page. Here's an audit of
current usages, and the ones I think need to cleaned up. The "unsafe"
ones do not appear to have any protections against the device page
being removed (get_dev_pagemap()). Yes, some of these were added by
me. The "unsafe? HMM" ones need HMM eyes because HMM leaks device
pages into anonymous memory paths and I'm not up to speed on how it
guarantees 'struct page' validity vs device shutdown without using
get_dev_pagemap().

smaps_pmd_entry(): unsafe

put_devmap_managed_page(): safe, page reference is held

is_device_private_page(): safe? gpu driver manages private page lifetime

is_pci_p2pdma_page(): safe, page reference is held

uncharge_page(): unsafe? HMM

add_to_kill(): safe, protected by get_dev_pagemap() and dax_lock_page()

soft_offline_page(): unsafe

remove_migration_pte(): unsafe? HMM

move_to_new_page(): unsafe? HMM

migrate_vma_pages() and helpers: unsafe? HMM

try_to_unmap_one(): unsafe? HMM

__put_page(): safe

release_pages(): safe

I'm hoping all the HMM ones can be converted to
is_device_private_page() directlly and have that routine grow a nice
comment about how it knows it can always safely de-reference its @page
argument.

For the rest I'd like to propose that we add a facility to determine
ZONE_DEVICE by pfn rather than page. The most straightforward why I
can think of would be to just add another bitmap to mem_section_usage
to indicate if a subsection is ZONE_DEVICE or not.


(it's a somewhat unrelated bigger discussion, but we can start discussing it in 
this thread)

I dislike this for three reasons

a) It does not protect against any races, really, it does not improve things.
b) We do have the exact same problem with pfn_to_online_page(). As long as we
don't hold the memory hotplug lock, memory can get offlined and remove any 
time. Racy.
c) We mix in ZONE specific stuff into the core. It should be "just another zone"

What I propose instead (already discussed in 
https://lkml.org/lkml/2019/10/10/87)

1. Convert SECTION_IS_ONLINE to SECTION_IS_ACTIVE
2. Convert SECTION_IS_ACTIVE to a subsection bitmap
3. Introduce pfn_active() that checks against the subsection bitmap
4. Once the memmap was initialized / prepared, set the subsection active
(similar to SECTION_IS_ONLINE in the buddy right now)
5. Before the memmap gets invalidated, set the subsection inactive
(similar to SECTION_IS_ONLINE in the buddy right now)
5. pfn_to_online_page() = pfn_active() && zone != ZONE_DEVICE
6. pfn_to_device_page() = pfn_active() && zone == ZONE_DEVICE



Dan, I am suspecting that you want a pfn_to_zone() that will not touch 
the memmap, because it could potentially (altmap) lie on slow memory, right?


A modification might make this possible (but I am not yet sure if we 
want a less generic MM implementation just to fine tune slow memmap 
access here)


1. Keep SECTION_IS_ONLINE as it is with the same semantics
2. Introduce a subsection bitmap to record active ("initialized memmap")
   PFNs. E.g., also set it when setting sections online.
3. Introduce pfn_active() that checks against the subsection bitmap
4. Once the memmap was initialized / prepared, set the subsection active
   (similar to SECTION_IS_ONLINE in the buddy right now)
5. Before the memmap gets invalidated, set the subsection inactive
   (similar to SECTION_IS_ONLINE in the buddy right now)
5. pfn_to_online_page() = pfn_active() && section == SECTION_IS_ONLINE
   (or keep it as is, depends on the RCU locking we eventually
implement)
6. pfn_to_device_page() = pfn_active() && section != SECTION_IS_ONLINE
7. use pfn_active() whenever we don't care about the zone.

Again, not really a friend of that, it hardcodes ZONE_DEVICE vs. 
!ZONE_DEVICE. When we do a random "pfn_to_page()" (e.g., a pfn walker) 
we really want to touch the memmap right away either way. So we can also 
directly read the zone from it. I really do prefer right now a more 
generic implementation.


--

Thanks,

David / dhildenb

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v1 09/10] mm/memory_hotplug: Don't mark pages PG_reserved when initializing the memmap

2019-10-24 Thread David Hildenbrand
Everything should be prepared to stop setting pages PG_reserved when
initializing the memmap on memory hotplug. Most importantly, we
stop marking ZONE_DEVICE pages PG_reserved.

a) We made sure that any code that relied on PG_reserved to detect
   ZONE_DEVICE memory will no longer rely on PG_reserved (especially,
   by relying on pfn_to_online_page() for now). Details can be found
   below.
b) We made sure that memory blocks with holes cannot be offlined and
   therefore also not onlined. We have quite some code that relies on
   memory holes being marked PG_reserved. This is now not an issue
   anymore.

generic_online_page() still calls __free_pages_core(), which performs
__ClearPageReserved(p). AFAIKS, this should not hurt.

It is worth nothing that the users of online_page_callback_t might see a
change. E.g., until now, pages not freed to the buddy by the HyperV
balloonm were set PG_reserved until freed via generic_online_page(). Now,
they would look like ordinarily allocated pages (refcount == 1). This
callback is used by the XEN balloon and the HyperV balloon. To not
introduce any silent errors, keep marking the pages PG_reserved. We can
most probably stop doing that, but have to double check if there are
issues (e.g., offlining code aborts right away in has_unmovable_pages()
when it runs into a PageReserved(page))

Update the documentation at various places in the MM core.

There are three PageReserved() users that might be affected by this change.
 - drivers/staging/gasket/gasket_page_table.c:gasket_release_page()
   -> We might (unlikely) set SetPageDirty() on a ZONE_DEVICE page
   -> I assume "we don't care"
 - drivers/staging/kpc2000/kpc_dma/fileops.c:transfer_complete_cb()
   -> We might (unlikely) set SetPageDirty() on a ZONE_DEVICE page
   -> I assume "we don't care"
 - mm/usercopy.c: check_page_span()
   -> According to Dan, non-HMM ZONE_DEVICE usage excluded this code since
  commit 52f476a323f9 ("libnvdimm/pmem: Bypass CONFIG_HARDENED_USERCOPY
  overhead")
   -> It is unclear whether we rally cared about ZONE_DEVICE here (HMM) or
  simply about "PG_reserved". The worst thing that could happen is a
  false negative with CONFIG_HARDENED_USERCOPY we should be able to
  identify easily.
   -> There is a discussion to rip out that code completely
   -> I assume "not relevant" / "we don't care"

I audited the other PageReserved() users. They don't affect ZONE_DEVICE:
 - mm/page_owner.c:pagetypeinfo_showmixedcount_print()
   -> Never called for ZONE_DEVICE, (+ pfn_to_online_page(pfn))
 - mm/page_owner.c:init_pages_in_zone()
   -> Never called for ZONE_DEVICE (!populated_zone(zone))
 - mm/page_ext.c:free_page_ext()
   -> Only a BUG_ON(PageReserved(page)), not relevant
 - mm/page_ext.c:has_unmovable_pages()
   -> Not releveant for ZONE_DEVICE
 - mm/page_ext.c:pfn_range_valid_contig()
   -> pfn_to_online_page() already guards us
 - mm/mempolicy.c:queue_pages_pte_range()
   -> vm_normal_page() checks against pte_devmap()
 - mm/memory-failure.c:hwpoison_user_mappings()
   -> Not reached via memory_failure() due to pfn_to_online_page()
   -> Also not reached indirectly via memory_failure_hugetlb()
 - mm/hugetlb.c:gather_bootmem_prealloc()
   -> Only a WARN_ON(PageReserved(page)), not relevant
 - kernel/power/snapshot.c:saveable_highmem_page()
   -> pfn_to_online_page() already guards us
 - kernel/power/snapshot.c:saveable_page()
   -> pfn_to_online_page() already guards us
 - fs/proc/task_mmu.c:can_gather_numa_stats()
   -> vm_normal_page() checks against pte_devmap()
 - fs/proc/task_mmu.c:can_gather_numa_stats_pmd
   -> vm_normal_page_pmd() checks against pte_devmap()
 - fs/proc/page.c:stable_page_flags()
   -> The reserved bit is simply copied, irrelevant
 - drivers/firmware/memmap.c:release_firmware_map_entry()
   -> really only a check to detect bootmem. Not relevant for ZONE_DEVICE
 - arch/ia64/kernel/mca_drv.c
 - arch/mips/mm/init.c
 - arch/mips/mm/ioremap.c
 - arch/nios2/mm/ioremap.c
 - arch/parisc/mm/ioremap.c
 - arch/sparc/mm/tlb.c
 - arch/xtensa/mm/cache.c
   -> No ZONE_DEVICE support
 - arch/powerpc/mm/init_64.c:vmemmap_free()
   -> Special-cases memmap on altmap
   -> Only a check for bootmem
 - arch/x86/kernel/alternative.c:__text_poke()
   -> Only a WARN_ON(!PageReserved(pages[0])) to verify it is bootmem
 - arch/x86/mm/init_64.c
   -> Only a check for bootmem

Cc: "K. Y. Srinivasan" 
Cc: Haiyang Zhang 
Cc: Stephen Hemminger 
Cc: Sasha Levin 
Cc: Boris Ostrovsky 
Cc: Juergen Gross 
Cc: Stefano Stabellini 
Cc: Andrew Morton 
Cc: Alexander Duyck 
Cc: Pavel Tatashin 
Cc: Vlastimil Babka 
Cc: Johannes Weiner 
Cc: Anthony Yznaga 
Cc: Michal Hocko 
Cc: Oscar Salvador 
Cc: Dan Williams 
Cc: Mel Gorman 
Cc: Mike Rapoport 
Cc: Anshuman Khandual 
Cc: Matt Sickler 
Cc: Kees Cook 
Suggested-by: Michal Hocko 
Signed-off-by: David Hildenbrand 
---
 drivers/hv/hv_balloon.c|  6 ++
 drivers/xen/balloon.c  |  7 +++
 include/linux/page-flags.h |  8 +---
 

[PATCH v1 08/10] x86/mm: Prepare __ioremap_check_ram() for PG_reserved changes

2019-10-24 Thread David Hildenbrand
Right now, ZONE_DEVICE memory is always set PG_reserved. We want to
change that.

Rewrite __ioremap_check_ram() to make sure the function produces the
same result once we stop setting ZONE_DEVICE pages PG_reserved.

Cc: Dave Hansen 
Cc: Andy Lutomirski 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: Borislav Petkov 
Cc: "H. Peter Anvin" 
Signed-off-by: David Hildenbrand 
---
 arch/x86/mm/ioremap.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index a39dcdb5ae34..db6913b48edf 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -77,10 +77,17 @@ static unsigned int __ioremap_check_ram(struct resource 
*res)
start_pfn = (res->start + PAGE_SIZE - 1) >> PAGE_SHIFT;
stop_pfn = (res->end + 1) >> PAGE_SHIFT;
if (stop_pfn > start_pfn) {
-   for (i = 0; i < (stop_pfn - start_pfn); ++i)
-   if (pfn_valid(start_pfn + i) &&
-   !PageReserved(pfn_to_page(start_pfn + i)))
+   for (i = 0; i < (stop_pfn - start_pfn); ++i) {
+   struct page *page;
+/*
+ * We treat any pages that are not online (not managed
+ * by the buddy) as not being RAM. This includes
+ * ZONE_DEVICE pages.
+ */
+   page = pfn_to_online_page(start_pfn + i);
+   if (page && !PageReserved(page))
return IORES_MAP_SYSTEM_RAM;
+   }
}
 
return 0;
-- 
2.21.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v1 07/10] powerpc/mm: Prepare maybe_pte_to_page() for PG_reserved changes

2019-10-24 Thread David Hildenbrand
Right now, ZONE_DEVICE memory is always set PG_reserved. We want to
change that.

Rewrite maybe_pte_to_page() to make sure the function produces the
same result once we stop setting ZONE_DEVICE pages PG_reserved.

Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: Christophe Leroy 
Cc: "Aneesh Kumar K.V" 
Cc: Allison Randal 
Cc: Nicholas Piggin 
Cc: Thomas Gleixner 
Signed-off-by: David Hildenbrand 
---
 arch/powerpc/mm/pgtable.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/mm/pgtable.c b/arch/powerpc/mm/pgtable.c
index e3759b69f81b..613c98fa7dc0 100644
--- a/arch/powerpc/mm/pgtable.c
+++ b/arch/powerpc/mm/pgtable.c
@@ -55,10 +55,12 @@ static struct page *maybe_pte_to_page(pte_t pte)
unsigned long pfn = pte_pfn(pte);
struct page *page;
 
-   if (unlikely(!pfn_valid(pfn)))
-   return NULL;
-   page = pfn_to_page(pfn);
-   if (PageReserved(page))
+   /*
+* We reject any pages that are not online (not managed by the buddy).
+* This includes ZONE_DEVICE pages.
+*/
+   page = pfn_to_online_page(pfn);
+   if (unlikely(!page || PageReserved(page)))
return NULL;
return page;
 }
-- 
2.21.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v1 10/10] mm/usercopy.c: Update comment in check_page_span() regarding ZONE_DEVICE

2019-10-24 Thread David Hildenbrand
ZONE_DEVICE (a.k.a. device memory) is no longer marked PG_reserved. Update
the comment.

While at it, make it match what the code is acutally doing (reject vs.
accept).

Cc: Kees Cook 
Cc: Andrew Morton 
Cc: "Isaac J. Manjarres" 
Cc: "Matthew Wilcox (Oracle)" 
Cc: Qian Cai 
Cc: Thomas Gleixner 
Signed-off-by: David Hildenbrand 
---
 mm/usercopy.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/usercopy.c b/mm/usercopy.c
index 660717a1ea5c..80f254024c97 100644
--- a/mm/usercopy.c
+++ b/mm/usercopy.c
@@ -199,9 +199,9 @@ static inline void check_page_span(const void *ptr, 
unsigned long n,
return;
 
/*
-* Reject if range is entirely either Reserved (i.e. special or
-* device memory), or CMA. Otherwise, reject since the object spans
-* several independently allocated pages.
+* Accept if the range is entirely either Reserved ("special") or
+* CMA. Otherwise, reject since the object spans several independently
+* allocated pages.
 */
is_reserved = PageReserved(page);
is_cma = is_migrate_cma_page(page);
-- 
2.21.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v1 06/10] powerpc/64s: Prepare hash_page_do_lazy_icache() for PG_reserved changes

2019-10-24 Thread David Hildenbrand
Right now, ZONE_DEVICE memory is always set PG_reserved. We want to
change that.

Rewrite hash_page_do_lazy_icache() to make sure the function produces the
same result once we stop setting ZONE_DEVICE pages PG_reserved.

Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: "Aneesh Kumar K.V" 
Cc: Christophe Leroy 
Cc: Nicholas Piggin 
Cc: Andrew Morton 
Cc: Mike Rapoport 
Cc: YueHaibing 
Signed-off-by: David Hildenbrand 
---
 arch/powerpc/mm/book3s64/hash_utils.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/mm/book3s64/hash_utils.c 
b/arch/powerpc/mm/book3s64/hash_utils.c
index 6c123760164e..a1566039e747 100644
--- a/arch/powerpc/mm/book3s64/hash_utils.c
+++ b/arch/powerpc/mm/book3s64/hash_utils.c
@@ -1084,13 +1084,15 @@ void hash__early_init_mmu_secondary(void)
  */
 unsigned int hash_page_do_lazy_icache(unsigned int pp, pte_t pte, int trap)
 {
-   struct page *page;
+   struct page *page = pfn_to_online_page(pte_pfn(pte));
 
-   if (!pfn_valid(pte_pfn(pte)))
+   /*
+* We ignore any pages that are not online (not managed by the buddy).
+* This includes ZONE_DEVICE pages.
+*/
+   if (!page)
return pp;
 
-   page = pte_page(pte);
-
/* page is dirty */
if (!test_bit(PG_arch_1, >flags) && !PageReserved(page)) {
if (trap == 0x400) {
-- 
2.21.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v1 04/10] vfio/type1: Prepare is_invalid_reserved_pfn() for PG_reserved changes

2019-10-24 Thread David Hildenbrand
Right now, ZONE_DEVICE memory is always set PG_reserved. We want to
change that.

KVM has this weird use case that you can map anything from /dev/mem
into the guest. pfn_valid() is not a reliable check whether the memmap
was initialized and can be touched. pfn_to_online_page() makes sure
that we have an initialized memmap (and don't have ZONE_DEVICE memory).

Rewrite is_invalid_reserved_pfn() similar to kvm_is_reserved_pfn() to make
sure the function produces the same result once we stop setting ZONE_DEVICE
pages PG_reserved.

Cc: Alex Williamson 
Cc: Cornelia Huck 
Signed-off-by: David Hildenbrand 
---
 drivers/vfio/vfio_iommu_type1.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 2ada8e6cdb88..f8ce8c408ba8 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -299,9 +299,15 @@ static int vfio_lock_acct(struct vfio_dma *dma, long 
npage, bool async)
  */
 static bool is_invalid_reserved_pfn(unsigned long pfn)
 {
-   if (pfn_valid(pfn))
-   return PageReserved(pfn_to_page(pfn));
+   struct page *page = pfn_to_online_page(pfn);
 
+   /*
+* We treat any pages that are not online (not managed by the buddy)
+* as reserved - this includes ZONE_DEVICE pages and pages without
+* a memmap (e.g., mapped via /dev/mem).
+*/
+   if (page)
+   return PageReserved(page);
return true;
 }
 
-- 
2.21.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v1 05/10] powerpc/book3s: Prepare kvmppc_book3s_instantiate_page() for PG_reserved changes

2019-10-24 Thread David Hildenbrand
Right now, ZONE_DEVICE memory is always set PG_reserved. We want to
change that.

KVM has this weird use case that you can map anything from /dev/mem
into the guest. pfn_valid() is not a reliable check whether the memmap
was initialized and can be touched. pfn_to_online_page() makes sure
that we have an initialized memmap (and don't have ZONE_DEVICE memory).

Rewrite kvmppc_book3s_instantiate_page() similar to kvm_is_reserved_pfn()
to make sure the function produces the same result once we stop setting
ZONE_DEVICE pages PG_reserved.

Cc: Paul Mackerras 
Cc: Benjamin Herrenschmidt 
Cc: Michael Ellerman 
Signed-off-by: David Hildenbrand 
---
 arch/powerpc/kvm/book3s_64_mmu_radix.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c 
b/arch/powerpc/kvm/book3s_64_mmu_radix.c
index 2d415c36a61d..05397c0561fc 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_radix.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c
@@ -801,12 +801,14 @@ int kvmppc_book3s_instantiate_page(struct kvm_vcpu *vcpu,
   writing, upgrade_p);
if (is_error_noslot_pfn(pfn))
return -EFAULT;
-   page = NULL;
-   if (pfn_valid(pfn)) {
-   page = pfn_to_page(pfn);
-   if (PageReserved(page))
-   page = NULL;
-   }
+   /*
+* We treat any pages that are not online (not managed by the
+* buddy) as reserved - this includes ZONE_DEVICE pages and
+* pages without a memmap (e.g., mapped via /dev/mem).
+*/
+   page = pfn_to_online_page(pfn);
+   if (page && PageReserved(page))
+   page = NULL;
}
 
/*
-- 
2.21.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v1 03/10] KVM: Prepare kvm_is_reserved_pfn() for PG_reserved changes

2019-10-24 Thread David Hildenbrand
Right now, ZONE_DEVICE memory is always set PG_reserved. We want to
change that.

KVM has this weird use case that you can map anything from /dev/mem
into the guest. pfn_valid() is not a reliable check whether the memmap
was initialized and can be touched. pfn_to_online_page() makes sure
that we have an initialized memmap (and don't have ZONE_DEVICE memory).

Rewrite kvm_is_reserved_pfn() to make sure the function produces the
same result once we stop setting ZONE_DEVICE pages PG_reserved.

Cc: Paolo Bonzini 
Cc: "Radim Krčmář" 
Cc: Michal Hocko 
Cc: Dan Williams 
Cc: KarimAllah Ahmed 
Signed-off-by: David Hildenbrand 
---
 virt/kvm/kvm_main.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index e9eb666eb6e8..9d18cc67d124 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -151,9 +151,15 @@ __weak int kvm_arch_mmu_notifier_invalidate_range(struct 
kvm *kvm,
 
 bool kvm_is_reserved_pfn(kvm_pfn_t pfn)
 {
-   if (pfn_valid(pfn))
-   return PageReserved(pfn_to_page(pfn));
+   struct page *page = pfn_to_online_page(pfn);
 
+   /*
+* We treat any pages that are not online (not managed by the buddy)
+* as reserved - this includes ZONE_DEVICE pages and pages without
+* a memmap (e.g., mapped via /dev/mem).
+*/
+   if (page)
+   return PageReserved(page);
return true;
 }
 
-- 
2.21.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v1 00/10] mm: Don't mark hotplugged pages PG_reserved (including ZONE_DEVICE)

2019-10-24 Thread David Hildenbrand
This is the result of a recent discussion with Michal ([1], [2]). Right
now we set all pages PG_reserved when initializing hotplugged memmaps. This
includes ZONE_DEVICE memory. In case of system memory, PG_reserved is
cleared again when onlining the memory, in case of ZONE_DEVICE memory
never.

In ancient times, we needed PG_reserved, because there was no way to tell
whether the memmap was already properly initialized. We now have
SECTION_IS_ONLINE for that in the case of !ZONE_DEVICE memory. ZONE_DEVICE
memory is already initialized deferred, and there shouldn't be a visible
change in that regard.

One of the biggest fears were side effects. I went ahead and audited all
users of PageReserved(). The details can be found in "mm/memory_hotplug:
Don't mark pages PG_reserved when initializing the memmap".

This patch set adapts all relevant users of PageReserved() to keep the
existing behavior in respect to ZONE_DEVICE pages. The biggest part part
that needs changes is KVM, to keep the existing behavior (that's all I
care about in this series).

Note that this series is able to rely completely on pfn_to_online_page().
No new is_zone_device_page() calles are introduced (as requested by Dan).
We are currently discussing a way to mark also ZONE_DEVICE memmaps as
active/initialized - pfn_active() - and lightweight locking to make sure
memmaps remain active (e.g., using RCU). We might later be able to convert
some suers of pfn_to_online_page() to pfn_active(). Details can be found
in [3], however, this represents yet another cleanup/fix we'll perform
on top of this cleanup.

I only gave it a quick test with DIMMs on x86-64, but didn't test the
ZONE_DEVICE part at all (any tips for a nice QEMU setup?). Also, I didn't
test the KVM parts (especially with ZONE_DEVICE pages or no memmap at all).
Compile-tested on x86-64 and PPC.

Based on next/master. The current version (kept updated) can be found at:
https://github.com/davidhildenbrand/linux.git online_reserved_cleanup

RFC -> v1:
- Dropped "staging/gasket: Prepare gasket_release_page() for PG_reserved
  changes"
- Dropped "staging: kpc2000: Prepare transfer_complete_cb() for PG_reserved
  changes"
- Converted "mm/usercopy.c: Prepare check_page_span() for PG_reserved
  changes" to "mm/usercopy.c: Update comment in check_page_span()
  regarding ZONE_DEVICE"
- No new users of is_zone_device_page() are introduced.
- Rephrased comments and patch descriptions.

[1] https://lkml.org/lkml/2019/10/21/736
[2] https://lkml.org/lkml/2019/10/21/1034
[3] https://www.spinics.net/lists/linux-mm/msg194112.html

Cc: Michal Hocko 
Cc: Dan Williams 
Cc: kvm-...@vger.kernel.org
Cc: linuxppc-...@lists.ozlabs.org
Cc: k...@vger.kernel.org
Cc: linux-hyp...@vger.kernel.org
Cc: de...@driverdev.osuosl.org
Cc: xen-de...@lists.xenproject.org
Cc: x...@kernel.org
Cc: Alexander Duyck 

David Hildenbrand (10):
  mm/memory_hotplug: Don't allow to online/offline memory blocks with
holes
  KVM: x86/mmu: Prepare kvm_is_mmio_pfn() for PG_reserved changes
  KVM: Prepare kvm_is_reserved_pfn() for PG_reserved changes
  vfio/type1: Prepare is_invalid_reserved_pfn() for PG_reserved changes
  powerpc/book3s: Prepare kvmppc_book3s_instantiate_page() for
PG_reserved changes
  powerpc/64s: Prepare hash_page_do_lazy_icache() for PG_reserved
changes
  powerpc/mm: Prepare maybe_pte_to_page() for PG_reserved changes
  x86/mm: Prepare __ioremap_check_ram() for PG_reserved changes
  mm/memory_hotplug: Don't mark pages PG_reserved when initializing the
memmap
  mm/usercopy.c: Update comment in check_page_span() regarding
ZONE_DEVICE

 arch/powerpc/kvm/book3s_64_mmu_radix.c | 14 +
 arch/powerpc/mm/book3s64/hash_utils.c  | 10 +++---
 arch/powerpc/mm/pgtable.c  | 10 +++---
 arch/x86/kvm/mmu.c | 29 ++---
 arch/x86/mm/ioremap.c  | 13 ++--
 drivers/hv/hv_balloon.c|  6 
 drivers/vfio/vfio_iommu_type1.c| 10 --
 drivers/xen/balloon.c  |  7 +
 include/linux/page-flags.h |  8 +
 mm/memory_hotplug.c| 43 +++---
 mm/page_alloc.c| 11 ---
 mm/usercopy.c  |  6 ++--
 virt/kvm/kvm_main.c| 10 --
 13 files changed, 111 insertions(+), 66 deletions(-)

-- 
2.21.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v1 02/10] KVM: x86/mmu: Prepare kvm_is_mmio_pfn() for PG_reserved changes

2019-10-24 Thread David Hildenbrand
Right now, ZONE_DEVICE memory is always set PG_reserved. We want to
change that.

KVM has this weird use case that you can map anything from /dev/mem
into the guest. pfn_valid() is not a reliable check whether the memmap
was initialized and can be touched. pfn_to_online_page() makes sure
that we have an initialized memmap (and don't have ZONE_DEVICE memory).

Rewrite kvm_is_mmio_pfn() to make sure the function produces the
same result once we stop setting ZONE_DEVICE pages PG_reserved.

Cc: Paolo Bonzini 
Cc: "Radim Krčmář" 
Cc: Sean Christopherson 
Cc: Vitaly Kuznetsov 
Cc: Wanpeng Li 
Cc: Jim Mattson 
Cc: Joerg Roedel 
Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: Borislav Petkov 
Cc: "H. Peter Anvin" 
Cc: KarimAllah Ahmed 
Cc: Michal Hocko 
Cc: Dan Williams 
Signed-off-by: David Hildenbrand 
---
 arch/x86/kvm/mmu.c | 29 +
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 24c23c66b226..f03089a336de 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -2962,20 +2962,25 @@ static bool mmu_need_write_protect(struct kvm_vcpu 
*vcpu, gfn_t gfn,
 
 static bool kvm_is_mmio_pfn(kvm_pfn_t pfn)
 {
+   struct page *page = pfn_to_online_page(pfn);
+
+   /*
+* ZONE_DEVICE pages are never online. Online pages that are reserved
+* either indicate the zero page or MMIO pages.
+*/
+   if (page)
+   return !is_zero_pfn(pfn) && PageReserved(pfn_to_page(pfn));
+
+   /*
+* Anything with a valid (but not online) memmap could be ZONE_DEVICE.
+* Treat only UC/UC-/WC pages as MMIO.
+*/
if (pfn_valid(pfn))
-   return !is_zero_pfn(pfn) && PageReserved(pfn_to_page(pfn)) &&
-   /*
-* Some reserved pages, such as those from NVDIMM
-* DAX devices, are not for MMIO, and can be mapped
-* with cached memory type for better performance.
-* However, the above check misconceives those pages
-* as MMIO, and results in KVM mapping them with UC
-* memory type, which would hurt the performance.
-* Therefore, we check the host memory type in addition
-* and only treat UC/UC-/WC pages as MMIO.
-*/
-   (!pat_enabled() || pat_pfn_immune_to_uc_mtrr(pfn));
+   return !pat_enabled() || pat_pfn_immune_to_uc_mtrr(pfn);
 
+   /*
+* Any RAM that has no memmap (e.g., mapped via /dev/mem) is not MMIO.
+*/
return !e820__mapped_raw_any(pfn_to_hpa(pfn),
 pfn_to_hpa(pfn + 1) - 1,
 E820_TYPE_RAM);
-- 
2.21.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v1 01/10] mm/memory_hotplug: Don't allow to online/offline memory blocks with holes

2019-10-24 Thread David Hildenbrand
Our onlining/offlining code is unnecessarily complicated. Only memory
blocks added during boot can have holes (a range that is not
IORESOURCE_SYSTEM_RAM). Hotplugged memory never has holes (e.g., see
add_memory_resource()). All boot memory is alread online.

Therefore, when we stop allowing to offline memory blocks with holes, we
implicitly no longer have to deal with onlining memory blocks with holes.

This allows to simplify the code. For example, we no longer have to
worry about marking pages that fall into memory holes PG_reserved when
onlining memory. We can stop setting pages PG_reserved.

Offlining memory blocks added during boot is usually not guranteed to work
either way (unmovable data might have easily ended up on that memory during
boot). So stopping to do that should not really hurt (+ people are not
even aware of a setup where that used to work and that the existing code
still works correctly with memory holes). For the use case of offlining
memory to unplug DIMMs, we should see no change. (holes on DIMMs would be
weird).

Please note that hardware errors (PG_hwpoison) are not memory holes and
not affected by this change when offlining.

Cc: Andrew Morton 
Cc: Michal Hocko 
Cc: Oscar Salvador 
Cc: Pavel Tatashin 
Cc: Dan Williams 
Cc: Anshuman Khandual 
Signed-off-by: David Hildenbrand 
---
 mm/memory_hotplug.c | 26 --
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 561371ead39a..8d81730cf036 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1447,10 +1447,19 @@ static void node_states_clear_node(int node, struct 
memory_notify *arg)
node_clear_state(node, N_MEMORY);
 }
 
+static int count_system_ram_pages_cb(unsigned long start_pfn,
+unsigned long nr_pages, void *data)
+{
+   unsigned long *nr_system_ram_pages = data;
+
+   *nr_system_ram_pages += nr_pages;
+   return 0;
+}
+
 static int __ref __offline_pages(unsigned long start_pfn,
  unsigned long end_pfn)
 {
-   unsigned long pfn, nr_pages;
+   unsigned long pfn, nr_pages = 0;
unsigned long offlined_pages = 0;
int ret, node, nr_isolate_pageblock;
unsigned long flags;
@@ -1461,6 +1470,20 @@ static int __ref __offline_pages(unsigned long start_pfn,
 
mem_hotplug_begin();
 
+   /*
+* Don't allow to offline memory blocks that contain holes.
+* Consecuently, memory blocks with holes can never get onlined
+* (hotplugged memory has no holes and all boot memory is online).
+* This allows to simplify the onlining/offlining code quite a lot.
+*/
+   walk_system_ram_range(start_pfn, end_pfn - start_pfn, _pages,
+ count_system_ram_pages_cb);
+   if (nr_pages != end_pfn - start_pfn) {
+   ret = -EINVAL;
+   reason = "memory holes";
+   goto failed_removal;
+   }
+
/* This makes hotplug much easier...and readable.
   we assume this for now. .*/
if (!test_pages_in_a_zone(start_pfn, end_pfn, _start,
@@ -1472,7 +1495,6 @@ static int __ref __offline_pages(unsigned long start_pfn,
 
zone = page_zone(pfn_to_page(valid_start));
node = zone_to_nid(zone);
-   nr_pages = end_pfn - start_pfn;
 
/* set above range as isolated */
ret = start_isolate_page_range(start_pfn, end_pfn,
-- 
2.21.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [Outreachy kernel] Re: [PATCH v2 1/5] staging: octeon: remove typedef declaration for cvmx_wqe

2019-10-24 Thread Wambui Karuga
On Thu, Oct 24, 2019 at 07:26:59AM +0200, Julia Lawall wrote:
> > If you're making significant changes to this driver, please test them
> > using the MIPS cavium_octeon_defconfig which is where this driver is
> > actually used.
> >
> > This driver has broken builds a few times recently which makes me very
> > tempted to ask that we stop allowing it to be built with COMPILE_TEST.
> > The whole octeon-stubs.h thing is a horrible hack anyway...
> 
> Wambui,
> 
> Please figure out what went wrong here.  Are there two sets of typedefs
> that should have been updated?
>
I managed to reproduce these build errors and finally noticed that the
"octeon-stubs.h" header is only included when CONFIG_CAVIUM_OCTEON_SOC
is not defined, therefore compiling properly for COMPILE_TEST but will
actually fail when compiled with CONFIG_CAVIUM_OCTEON_SOC is set since
the functions will try to use the definitions in
arch/mips/include/asm/octeon/ that don't have the changes.

Paul, please tell me if this is correct?

Thanks,
wambui

> Others,
> 
> Would it be reasonable to put the information about how the driver should
> be compied in the TODO file?  git grep cavium_octeon_defconfig in the
> octeon directory turns up nothing.
> 
> thanks,
> julia
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to outreachy-kernel+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/alpine.DEB.2.21.1910240722070.2771%40hadrien.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: exfat: add exfat filesystem code to staging

2019-10-24 Thread Pali Rohár
On Wednesday 28 August 2019 18:08:17 Greg Kroah-Hartman wrote:
> The full specification of the filesystem can be found at:
>   https://docs.microsoft.com/en-us/windows/win32/fileio/exfat-specification

FYI, it looks like that this released specification is just copy+paste
from exFAT patent https://patents.google.com/patent/US20150370821 which
was there publicly available for a while. And similar/same? copy was
available on the following site https://www.ntfs.com/exfat-overview.htm

-- 
Pali Rohár
pali.ro...@gmail.com
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RFC v1 01/12] mm/memory_hotplug: Don't allow to online/offline memory blocks with holes

2019-10-24 Thread David Hildenbrand

On 24.10.19 05:53, Anshuman Khandual wrote:


On 10/22/2019 10:42 PM, David Hildenbrand wrote:

Our onlining/offlining code is unnecessarily complicated. Only memory
blocks added during boot can have holes. Hotplugged memory never has
holes. That memory is already online.


Why hot plugged memory at runtime cannot have holes (e.g a semi bad DIMM).


Important: HWPoison != memory hole

A memory hole is memory that is not "IORESOURCE_SYSRAM". These pages are 
currently marked PG_reserved. Such holes are sometimes used for mapping 
something into kernel space. Some archs use the PG_reserved to detect 
the memory hole ("not ram") and ignore the memmap.


Poisoned pages are marked PG_hwpoison.


Currently, do we just abort adding that memory block if there are holes ?


There is no interface to do that.

E.g., have a look at add_memory() add_memory_resource(). You can only 
pass one memory resource (that is all IORESOURCE_SYSRAM | IORESOURCE_BUSY)


Hotplugging memory with holes is not supported (nor can I imagine a use 
case for that).




When we stop allowing to offline memory blocks with holes, we implicitly
stop to online memory blocks with holes.


Reducing hotplug support for memory blocks with holes just to simplify
the code. Is it worth ?


Me and Michal are not aware of a users, not even aware of a use case. 
Keeping code around that nobody really needs that limits cleanups, no 
thanks. Similar to us not supporting to offline memory blocks that span 
multiple nodes/zones.


E.g., have a look at the isolation code. It is full of code that jumps 
over memory holes (start_isolate_page_range() -> __first_valid_page()). 
That made sense for our complicated memory offlining code, but it is 
actually harmful when dealing with alloc_contig_range(). Allocation 
never wants to jump over memory holes. After this patch, we can just 
fail hard on any memory hole we detect, instead of ignoring it (or 
special-casing it).






This allows to simplify the code. For example, we no longer have to
worry about marking pages that fall into memory holes PG_reserved when
onlining memory. We can stop setting pages PG_reserved.


Could not there be any other way of tracking these holes if not the page
reserved bit. In the memory section itself and corresponding struct pages
just remained poisoned ? Just wondering, might be all wrong here.


Of course there could be ways (e.g., using PG_offline eventually), but 
it boils down to us having to deal with it in onlining/offlining code. 
And that is some handling nobody really seems to need.






Offlining memory blocks added during boot is usually not guranteed to work
either way. So stopping to do that (if anybody really used and tested


That guarantee does not exist right now because how boot memory could have
been used after boot not from a limitation of the memory hot remove itself.


Yep. However, Michal and I are not even aware of a setup that would made 
this work and guarantee that the existing code actually still is able to 
deal with holes. Are you?





this over the years) should not really hurt. For the use case of
offlining memory to unplug DIMMs, we should see no change. (holes on
DIMMs would be weird)


Holes on DIMM could be due to HW errors affecting only parts of it. By not


Again, HW errors != holes. We have PG_hwpoison for that.


allowing such DIMM's hot add and remove, we are definitely reducing the
scope of overall hotplug functionality. Is code simplification in itself
is worth this reduction in functionality ?


What you describe is not affected.

Thanks!

--

Thanks,

David / dhildenb

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel