lkml.org 
[lkml]   [2019]   [Mar]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 2/6] leds: netdev trigger: factor out middle part of device_name_store
Hi!

> Take the part of device_name_store that puts the old device (if any),
> copies the new device name, looks the name up etc. into a separate
> helper function. This is preparation for using that helper from a
> function that will initialize the led_netdev_data from a device tree
> node. No functional change.
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---
> drivers/leds/trigger/ledtrig-netdev.c | 30 ++++++++++++++++-----------
> 1 file changed, 18 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/leds/trigger/ledtrig-netdev.c b/drivers/leds/trigger/ledtrig-netdev.c
> index 8d476b92f58c..21605033e322 100644
> --- a/drivers/leds/trigger/ledtrig-netdev.c
> +++ b/drivers/leds/trigger/ledtrig-netdev.c
> @@ -104,19 +104,9 @@ static ssize_t device_name_show(struct device *dev,
> return len;
> }
>
> -static ssize_t device_name_store(struct device *dev,
> - struct device_attribute *attr, const char *buf,
> - size_t size)
> +static void netdev_trig_set_device(struct led_netdev_data *trigger_data,
> + const char *buf, size_t size)
> {
> - struct led_netdev_data *trigger_data = led_trigger_get_drvdata(dev);
> -
> - if (size >= IFNAMSIZ)
> - return -EINVAL;
> -
> - cancel_delayed_work_sync(&trigger_data->work);
> -
> - spin_lock_bh(&trigger_data->lock);
> -
> if (trigger_data->net_dev) {
> dev_put(trigger_data->net_dev);
> trigger_data->net_dev = NULL;

I'd expect the helper function to do the >= IFNAMSIZ checking... but
not a huge deal.

Pavel

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2019-03-18 12:25    [W:0.184 / U:7.624 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site