1. 20 Oct, 2023 1 commit
    • Przemek Kitszel's avatar
      devlink: retain error in struct devlink_fmsg · db80d3b2
      Przemek Kitszel authored
      Retain error value in struct devlink_fmsg, to relieve drivers from
      checking it after each call.
      Note that fmsg is an in-memory builder/buffer of formatted message,
      so it's not the case that half baked message was sent somewhere.
      
      We could find following scheme in multiple drivers:
        err = devlink_fmsg_obj_nest_start(fmsg);
        if (err)
        	return err;
        err = devlink_fmsg_string_pair_put(fmsg, "src", src);
        if (err)
        	return err;
        err = devlink_fmsg_something(fmsg, foo, bar);
        if (err)
      	return err;
        // and so on...
        err = devlink_fmsg_obj_nest_end(fmsg);
      
      With retaining error API that translates to:
        devlink_fmsg_obj_nest_start(fmsg);
        devlink_fmsg_string_pair_put(fmsg, "src", src);
        devlink_fmsg_something(fmsg, foo, bar);
        // and so on...
        devlink_fmsg_obj_nest_end(fmsg);
      
      What means we check error just when is time to send.
      
      Possible error scenarios are developer error (API misuse) and memory
      exhaustion, both cases are good candidates to choose readability
      over fastest possible exit.
      
      Note that this patch keeps returning errors, to allow per-driver conversion
      to the new API, but those are not needed at this point already.
      
      This commit itself is an illustration of benefits for the dev-user,
      more of it will be in separate commits of the series.
      Reviewed-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
      Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
      Signed-off-by: default avatarPrzemek Kitszel <przemyslaw.kitszel@intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      db80d3b2
  2. 19 Oct, 2023 39 commits