diff mbox series

[net-next,v1,1/5] ptp_ocp: use dev_err_probe()

Message ID 20220608120358.81147-2-andriy.shevchenko@linux.intel.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series ptp_ocp: set of small cleanups | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 3 of 3 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch warning WARNING: line length of 84 exceeds 80 columns WARNING: line length of 90 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Andy Shevchenko June 8, 2022, 12:03 p.m. UTC
Simplify the error path in ->probe() and unify message format a bit
by using dev_err_probe().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/ptp/ptp_ocp.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

Comments

Vadim Fedorenko June 8, 2022, 9:37 p.m. UTC | #1
On 08.06.2022 13:03, Andy Shevchenko wrote:
> Simplify the error path in ->probe() and unify message format a bit
> by using dev_err_probe().
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

LGTM

Acked-by: Vadim Fedorenko <vfedorenko@novek.ru>
> ---
>   drivers/ptp/ptp_ocp.c | 13 +++++--------
>   1 file changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index 4519ef42b458..17930762fde9 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -3722,14 +3722,12 @@ ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>   	int err;
>   
>   	devlink = devlink_alloc(&ptp_ocp_devlink_ops, sizeof(*bp), &pdev->dev);
> -	if (!devlink) {
> -		dev_err(&pdev->dev, "devlink_alloc failed\n");
> -		return -ENOMEM;
> -	}
> +	if (!devlink)
> +		return dev_err_probe(&pdev->dev, -ENOMEM, "devlink_alloc failed\n");
>   
>   	err = pci_enable_device(pdev);
>   	if (err) {
> -		dev_err(&pdev->dev, "pci_enable_device\n");
> +		dev_err_probe(&pdev->dev, err, "pci_enable_device\n");
>   		goto out_free;
>   	}
>   
> @@ -3745,7 +3743,7 @@ ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>   	 */
>   	err = pci_alloc_irq_vectors(pdev, 1, 17, PCI_IRQ_MSI | PCI_IRQ_MSIX);
>   	if (err < 0) {
> -		dev_err(&pdev->dev, "alloc_irq_vectors err: %d\n", err);
> +		dev_err_probe(&pdev->dev, err, "alloc_irq_vectors\n");
>   		goto out;
>   	}
>   	bp->n_irqs = err;
> @@ -3757,8 +3755,7 @@ ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>   
>   	bp->ptp = ptp_clock_register(&bp->ptp_info, &pdev->dev);
>   	if (IS_ERR(bp->ptp)) {
> -		err = PTR_ERR(bp->ptp);
> -		dev_err(&pdev->dev, "ptp_clock_register: %d\n", err);
> +		err = dev_err_probe(&pdev->dev, PTR_ERR(bp->ptp), "ptp_clock_register\n");
>   		bp->ptp = NULL;
>   		goto out;
>   	}
Jonathan Lemon June 8, 2022, 10:20 p.m. UTC | #2
On Wed, Jun 08, 2022 at 03:03:54PM +0300, Andy Shevchenko wrote:
> Simplify the error path in ->probe() and unify message format a bit
> by using dev_err_probe().

Line length.
Jakub Kicinski June 10, 2022, 5:45 a.m. UTC | #3
On Wed,  8 Jun 2022 15:03:54 +0300 Andy Shevchenko wrote:
> Simplify the error path in ->probe() and unify message format a bit
> by using dev_err_probe().

Let's not do this. I get that using dev_err_probe() even without
possibility of -EPROBE_DEFER is acceptable, but converting
existing drivers is too much IMO. Acceptable < best practice.
Andy Shevchenko June 10, 2022, 11:09 a.m. UTC | #4
On Thu, Jun 09, 2022 at 10:45:23PM -0700, Jakub Kicinski wrote:
> On Wed,  8 Jun 2022 15:03:54 +0300 Andy Shevchenko wrote:
> > Simplify the error path in ->probe() and unify message format a bit
> > by using dev_err_probe().
> 
> Let's not do this. I get that using dev_err_probe() even without
> possibility of -EPROBE_DEFER is acceptable, but converting
> existing drivers is too much IMO. Acceptable < best practice.

Noted.

I have just checked that if you drop this patch the rest will be still
applicable. If you have no objections, can you apply patches 2-5 then?
Jakub Kicinski June 10, 2022, 3:39 p.m. UTC | #5
On Fri, 10 Jun 2022 14:09:24 +0300 Andy Shevchenko wrote:
> I have just checked that if you drop this patch the rest will be still
> applicable. If you have no objections, can you apply patches 2-5 then?

It's tradition in netdev to ask people to repost. But looks completely
safe for me to drop patch 1, so applied 2-5. Don't tell anyone I did this.
Jonathan Lemon June 10, 2022, 3:46 p.m. UTC | #6
On Fri, Jun 10, 2022 at 08:39:18AM -0700, Jakub Kicinski wrote:
> On Fri, 10 Jun 2022 14:09:24 +0300 Andy Shevchenko wrote:
> > I have just checked that if you drop this patch the rest will be still
> > applicable. If you have no objections, can you apply patches 2-5 then?
> 
> It's tradition in netdev to ask people to repost. But looks completely
> safe for me to drop patch 1, so applied 2-5. Don't tell anyone I did this.

I see what you did there.  :)
Andy Shevchenko June 10, 2022, 4:04 p.m. UTC | #7
On Fri, Jun 10, 2022 at 5:43 PM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Fri, 10 Jun 2022 14:09:24 +0300 Andy Shevchenko wrote:
> > I have just checked that if you drop this patch the rest will be still
> > applicable. If you have no objections, can you apply patches 2-5 then?
>
> It's tradition in netdev to ask people to repost. But looks completely
> safe for me to drop patch 1, so applied 2-5.

Thanks!

> Don't tell anyone I did this.

Tschhh!
diff mbox series

Patch

diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 4519ef42b458..17930762fde9 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -3722,14 +3722,12 @@  ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	int err;
 
 	devlink = devlink_alloc(&ptp_ocp_devlink_ops, sizeof(*bp), &pdev->dev);
-	if (!devlink) {
-		dev_err(&pdev->dev, "devlink_alloc failed\n");
-		return -ENOMEM;
-	}
+	if (!devlink)
+		return dev_err_probe(&pdev->dev, -ENOMEM, "devlink_alloc failed\n");
 
 	err = pci_enable_device(pdev);
 	if (err) {
-		dev_err(&pdev->dev, "pci_enable_device\n");
+		dev_err_probe(&pdev->dev, err, "pci_enable_device\n");
 		goto out_free;
 	}
 
@@ -3745,7 +3743,7 @@  ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	 */
 	err = pci_alloc_irq_vectors(pdev, 1, 17, PCI_IRQ_MSI | PCI_IRQ_MSIX);
 	if (err < 0) {
-		dev_err(&pdev->dev, "alloc_irq_vectors err: %d\n", err);
+		dev_err_probe(&pdev->dev, err, "alloc_irq_vectors\n");
 		goto out;
 	}
 	bp->n_irqs = err;
@@ -3757,8 +3755,7 @@  ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	bp->ptp = ptp_clock_register(&bp->ptp_info, &pdev->dev);
 	if (IS_ERR(bp->ptp)) {
-		err = PTR_ERR(bp->ptp);
-		dev_err(&pdev->dev, "ptp_clock_register: %d\n", err);
+		err = dev_err_probe(&pdev->dev, PTR_ERR(bp->ptp), "ptp_clock_register\n");
 		bp->ptp = NULL;
 		goto out;
 	}