From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>,
David Rientjes <rientjes@google.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] radio-shark: Only compile led support when CONFIG_LED_CLASS is set
Date: Fri, 10 Aug 2012 17:15:49 -0300 [thread overview]
Message-ID: <50256BF5.7090704@redhat.com> (raw)
In-Reply-To: <1344628686-10482-1-git-send-email-hdegoede@redhat.com>
Em 10-08-2012 16:58, Hans de Goede escreveu:
> Reported-by: Dadiv Rientjes <rientjes@google.com>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> drivers/media/radio/radio-shark.c | 26 ++++++++++++++++++++++++--
> 1 file changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
> index c2ead23..f746ed0 100644
> --- a/drivers/media/radio/radio-shark.c
> +++ b/drivers/media/radio/radio-shark.c
> @@ -27,7 +27,6 @@
>
> #include <linux/init.h>
> #include <linux/kernel.h>
> -#include <linux/leds.h>
> #include <linux/module.h>
> #include <linux/slab.h>
> #include <linux/usb.h>
> @@ -35,6 +34,12 @@
> #include <media/v4l2-device.h>
> #include <sound/tea575x-tuner.h>
>
> +#if defined(CONFIG_LEDS_CLASS) || \
> + (defined(CONFIG_LEDS_CLASS_MODULE) && defined(CONFIG_RADIO_SHARK_MODULE))
> +#include <linux/leds.h>
Conditionally including headers is not a good thing.
...
> static void usb_shark_disconnect(struct usb_interface *intf)
> {
> struct v4l2_device *v4l2_dev = usb_get_intfdata(intf);
> struct shark_device *shark = v4l2_dev_to_shark(v4l2_dev);
> +#ifdef SHARK_USE_LEDS
> int i;
> +#endif
>
> mutex_lock(&shark->tea.mutex);
> v4l2_device_disconnect(&shark->v4l2_dev);
> snd_tea575x_exit(&shark->tea);
> mutex_unlock(&shark->tea.mutex);
>
> +#ifdef SHARK_USE_LEDS
> for (i = 0; i < NO_LEDS; i++)
> led_classdev_unregister(&shark->leds[i]);
> +#endif
>
> v4l2_device_put(&shark->v4l2_dev);
> }
That looks ugly. Maybe you could code it on a different way.
You could be move all shark_use_leds together into the same place at
the code, like:
#if defined(CONFIG_LEDS_CLASS) || \
(defined(CONFIG_LEDS_CLASS_MODULE) && defined(CONFIG_RADIO_SHARK_MODULE))
static void shark_led_set_blue(struct led_classdev *led_cdev,
...
.brightness_set = shark_led_set_red,
},
};
static void shark_led_disconnect(...)
{
...
}
static void shark_led_release(...)
{
...
}
static void shark_led_register(...)
{
...
}
#else
static inline void shark_led_disconnect(...) { };
static inline void shark_led_release(...) { };
static inline void shark_led_register(...)
{
printk(KERN_WARN "radio-shark: CONFIG_LED_CLASS not enabled. LEDs won't work\n");
}
#endif
And let the rest of the code to call the shark_led functions, as if LEDS aren't enabled,
the function stubs won't produce any code (well, except for the above error notice).
The same comment also applies to patch 2.
Regards,
Mauro
next prev parent reply other threads:[~2012-08-10 20:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-10 19:58 [PATCH 1/2] radio-shark: Only compile led support when CONFIG_LED_CLASS is set Hans de Goede
2012-08-10 19:58 ` [PATCH 2/2] radio-shark2: " Hans de Goede
2012-08-10 20:15 ` Mauro Carvalho Chehab [this message]
2012-08-11 7:35 ` [PATCH 1/2] radio-shark: " Hans de Goede
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=50256BF5.7090704@redhat.com \
--to=mchehab@redhat.com \
--cc=hdegoede@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=rientjes@google.com \
/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;
as well as URLs for NNTP newsgroup(s).