public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Rahul Rameshbabu via ltp <ltp@lists.linux.it>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Linux Kernel Functional Testing <lkft@linaro.org>,
	netdev@vger.kernel.org,
	Richard Cochran <richardcochran@gmail.com>,
	lkft-triage@lists.linaro.org,
	"David S. Miller" <davem@davemloft.net>,
	Nathan Chancellor <nathan@kernel.org>,
	Saeed Mahameed <saeed@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Gal Pressman <gal@nvidia.com>, LTP List <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH net v1] ptp: Make max_phase_adjustment sysfs device attribute invisible when not supported
Date: Wed, 28 Jun 2023 13:55:53 -0700	[thread overview]
Message-ID: <87edlvqpba.fsf@nvidia.com> (raw)
In-Reply-To: <06f5c065-2c6d-4cd2-9699-89f05443f137@lunn.ch> (Andrew Lunn's message of "Wed, 28 Jun 2023 22:46:32 +0200")

On Wed, 28 Jun, 2023 22:46:32 +0200 Andrew Lunn <andrew@lunn.ch> wrote:
> On Wed, Jun 28, 2023 at 01:38:50PM -0700, Jakub Kicinski wrote:
>> On Wed, 28 Jun 2023 03:16:43 +0200 Andrew Lunn wrote:
>> > > +	} else if (attr == &dev_attr_max_phase_adjustment.attr) {
>> > > +		if (!info->adjphase || !info->getmaxphase)
>> > > +			mode = 0;  
>> > 
>> > Maybe it is time to turn this into a switch statement?
>> 
>> I don't think we can switch on pointers in C.
>
> https://elixir.bootlin.com/linux/latest/source/drivers/net/phy/sfp.c#L749
>
> Works for temperature sensors, voltage sensors, current sensors, and
> power sensors. Maybe hwmon is different to what is going on here, but
> both a sysfs files.

Sorry, the only switch cases I see in the link you shared are for an
integral type enum and a u32. I do not see a pointer type being used in
a switch in sfp_hwmon_is_visible?

I believe Jakub is right about pointer types + switches in C. pointer
types are not considered integral types. Here is a compiler explorer
example to demonstrate. This slipped my mind during our discussion.

https://godbolt.org/z/nKr3x7cT8

  <source>: In function 'main':
  <source>:6:13: error: switch quantity not an integer
      6 |     switch (data) {
        |             ^~~~
  Compiler returned: 1

-- Rahul Rameshbabu

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2023-06-29  9:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-27 23:21 [LTP] [PATCH net v1] ptp: Make max_phase_adjustment sysfs device attribute invisible when not supported Rahul Rameshbabu via ltp
2023-06-27 23:33 ` Nathan Chancellor
2023-06-28  1:16 ` Andrew Lunn
2023-06-28  2:22   ` Rahul Rameshbabu via ltp
2023-06-28 14:35     ` Andrew Lunn
2023-06-28 17:48       ` Rahul Rameshbabu via ltp
2023-06-28 18:15         ` Andrew Lunn
2023-06-28 20:38   ` Jakub Kicinski
2023-06-28 20:46     ` Andrew Lunn
2023-06-28 20:55       ` Rahul Rameshbabu via ltp [this message]
2023-06-29 18:06 ` Jakub Kicinski
2023-06-30  3:33   ` Richard Cochran
2023-06-30  3:32 ` Richard Cochran
2023-07-03  5:10 ` Petr Vorel
2023-07-03 12:53   ` Cyril Hrubis
2023-07-03 20:40 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87edlvqpba.fsf@nvidia.com \
    --to=ltp@lists.linux.it \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=gal@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=lkft-triage@lists.linaro.org \
    --cc=lkft@linaro.org \
    --cc=nathan@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=rrameshbabu@nvidia.com \
    --cc=saeed@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox